Improved affiliate selection.
This commit is contained in:
@@ -27,6 +27,7 @@ export function curateEntity(entity, context) {
|
||||
children: context?.children?.filter((child) => child.parent_id === entity.id).map((child) => curateEntity({ ...child, parent: entity }, { parent: entity })) || [],
|
||||
affiliate: entity.affiliate ? {
|
||||
id: entity.affiliate.id,
|
||||
entityId: entity.affiliate.entity_id,
|
||||
url: entity.affiliate.url,
|
||||
parameters: entity.affiliate.parameters,
|
||||
} : null,
|
||||
@@ -106,7 +107,8 @@ export async function fetchEntitiesById(entityIds, options = {}, reqUser) {
|
||||
builder.orderBy(...options.order);
|
||||
}
|
||||
})
|
||||
.groupBy('entities.id', 'parents.id', 'affiliates.id'),
|
||||
.orderBy(knex.raw('case when affiliates.entity_id = entities.id then 1 else 2 end'))
|
||||
.groupBy('entities.id', 'parents.id', 'affiliates.id', 'affiliates.entity_id'),
|
||||
options.includeChildren ? knex('entities')
|
||||
.whereIn('entities.parent_id', entityIds)
|
||||
.whereNot('type', 'info')
|
||||
|
||||
Reference in New Issue
Block a user