Added affiliate parameters to scene URL.
This commit is contained in:
@@ -19,6 +19,11 @@ export function curateEntity(entity, context) {
|
||||
hasLogo: entity.has_logo,
|
||||
parent: curateEntity(entity.parent, 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,
|
||||
url: entity.affiliate.url,
|
||||
parameters: entity.affiliate.parameters,
|
||||
} : null,
|
||||
...context?.append?.[entity.id],
|
||||
};
|
||||
}
|
||||
@@ -66,15 +71,20 @@ export async function fetchEntities(options) {
|
||||
export async function fetchEntitiesById(entityIds, options = {}) {
|
||||
const [entities, children] = await Promise.all([
|
||||
knex('entities')
|
||||
.select('entities.*', knex.raw('row_to_json(parents) as parent'))
|
||||
.select(
|
||||
'entities.*',
|
||||
knex.raw('row_to_json(parents) as parent'),
|
||||
knex.raw('row_to_json(affiliates) as affiliate'),
|
||||
)
|
||||
.whereIn('entities.id', entityIds)
|
||||
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
|
||||
.leftJoin('affiliates', knex.raw('affiliates.entity_id in (entities.id, parents.id)'))
|
||||
.modify((builder) => {
|
||||
if (options.order) {
|
||||
builder.orderBy(...options.order);
|
||||
}
|
||||
})
|
||||
.groupBy('entities.id', 'parents.id'),
|
||||
.groupBy('entities.id', 'parents.id', 'affiliates.id'),
|
||||
options.includeChildren ? knex('entities')
|
||||
.whereIn('entities.parent_id', entityIds)
|
||||
.orderBy('slug') : [],
|
||||
|
||||
Reference in New Issue
Block a user