Improved affiliate selection.
This commit is contained in:
parent
50280692e8
commit
b355ef4bf5
|
@ -168,16 +168,21 @@ const entityUrl = (() => {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!entity.affiliate?.parameters) {
|
||||
return entity.url;
|
||||
// affiliate might be inherited, only use full URL when directly associated
|
||||
if (entity.affiliate?.url && entity.affiliate.entityId === entity.id) {
|
||||
return entity.affiliate.url;
|
||||
}
|
||||
|
||||
const newParams = new URLSearchParams({
|
||||
...Object.fromEntries(new URL(entity.url).searchParams),
|
||||
...Object.fromEntries(new URLSearchParams(entity.affiliate.parameters)),
|
||||
});
|
||||
if (entity.affiliate?.parameters) {
|
||||
const newParams = new URLSearchParams({
|
||||
...Object.fromEntries(new URL(entity.url).searchParams),
|
||||
...Object.fromEntries(new URLSearchParams(entity.affiliate.parameters)),
|
||||
});
|
||||
|
||||
return `${entity.url}?${newParams}`;
|
||||
return `${entity.url}?${newParams}`;
|
||||
}
|
||||
|
||||
return entity.url;
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
|
|
@ -54,12 +54,12 @@ export async function onBeforeRender(pageContext) {
|
|||
const campaigns = await getRandomCampaigns([
|
||||
{
|
||||
entityIds: [entity.id, entity.parent?.id].filter(Boolean),
|
||||
minRatio: 1.5,
|
||||
minRatio: 3,
|
||||
allowRandomFallback: false,
|
||||
},
|
||||
{
|
||||
entityIds: [entity.id, entity.parent?.id].filter(Boolean),
|
||||
minRatio: 1.5,
|
||||
minRatio: 3,
|
||||
allowRandomFallback: false,
|
||||
},
|
||||
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 })) || [],
|
||||
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')
|
||||
|
|
2
static
2
static
|
@ -1 +1 @@
|
|||
Subproject commit d491eaf87d506618df464c87f2d2c8829e887d64
|
||||
Subproject commit 1fc67541d5b45b0e20d27cd366a01f9a83e444cc
|
Loading…
Reference in New Issue