Improved affiliate selection.
This commit is contained in:
parent
50280692e8
commit
b355ef4bf5
|
|
@ -168,16 +168,21 @@ const entityUrl = (() => {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.affiliate?.parameters) {
|
// affiliate might be inherited, only use full URL when directly associated
|
||||||
return entity.url;
|
if (entity.affiliate?.url && entity.affiliate.entityId === entity.id) {
|
||||||
|
return entity.affiliate.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity.affiliate?.parameters) {
|
||||||
const newParams = new URLSearchParams({
|
const newParams = new URLSearchParams({
|
||||||
...Object.fromEntries(new URL(entity.url).searchParams),
|
...Object.fromEntries(new URL(entity.url).searchParams),
|
||||||
...Object.fromEntries(new URLSearchParams(entity.affiliate.parameters)),
|
...Object.fromEntries(new URLSearchParams(entity.affiliate.parameters)),
|
||||||
});
|
});
|
||||||
|
|
||||||
return `${entity.url}?${newParams}`;
|
return `${entity.url}?${newParams}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return entity.url;
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,12 @@ export async function onBeforeRender(pageContext) {
|
||||||
const campaigns = await getRandomCampaigns([
|
const campaigns = await getRandomCampaigns([
|
||||||
{
|
{
|
||||||
entityIds: [entity.id, entity.parent?.id].filter(Boolean),
|
entityIds: [entity.id, entity.parent?.id].filter(Boolean),
|
||||||
minRatio: 1.5,
|
minRatio: 3,
|
||||||
allowRandomFallback: false,
|
allowRandomFallback: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
entityIds: [entity.id, entity.parent?.id].filter(Boolean),
|
entityIds: [entity.id, entity.parent?.id].filter(Boolean),
|
||||||
minRatio: 1.5,
|
minRatio: 3,
|
||||||
allowRandomFallback: false,
|
allowRandomFallback: false,
|
||||||
},
|
},
|
||||||
pageContext.routeParams.domain === 'scenes' ? {
|
pageContext.routeParams.domain === 'scenes' ? {
|
||||||
|
|
|
||||||
|
|
@ -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 })) || [],
|
children: context?.children?.filter((child) => child.parent_id === entity.id).map((child) => curateEntity({ ...child, parent: entity }, { parent: entity })) || [],
|
||||||
affiliate: entity.affiliate ? {
|
affiliate: entity.affiliate ? {
|
||||||
id: entity.affiliate.id,
|
id: entity.affiliate.id,
|
||||||
|
entityId: entity.affiliate.entity_id,
|
||||||
url: entity.affiliate.url,
|
url: entity.affiliate.url,
|
||||||
parameters: entity.affiliate.parameters,
|
parameters: entity.affiliate.parameters,
|
||||||
} : null,
|
} : null,
|
||||||
|
|
@ -106,7 +107,8 @@ export async function fetchEntitiesById(entityIds, options = {}, reqUser) {
|
||||||
builder.orderBy(...options.order);
|
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')
|
options.includeChildren ? knex('entities')
|
||||||
.whereIn('entities.parent_id', entityIds)
|
.whereIn('entities.parent_id', entityIds)
|
||||||
.whereNot('type', 'info')
|
.whereNot('type', 'info')
|
||||||
|
|
|
||||||
2
static
2
static
|
|
@ -1 +1 @@
|
||||||
Subproject commit d491eaf87d506618df464c87f2d2c8829e887d64
|
Subproject commit 1fc67541d5b45b0e20d27cd366a01f9a83e444cc
|
||||||
Loading…
Reference in New Issue