Compare commits

...

2 Commits

Author SHA1 Message Date
DebaucheryLibrarian 2afcdd6050 0.41.5 2025-10-06 05:20:19 +02:00
DebaucheryLibrarian b355ef4bf5 Improved affiliate selection. 2025-10-06 05:20:17 +02:00
6 changed files with 21 additions and 14 deletions

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{ {
"name": "traxxx-web", "name": "traxxx-web",
"version": "0.41.4", "version": "0.41.5",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"version": "0.41.4", "version": "0.41.5",
"dependencies": { "dependencies": {
"@brillout/json-serializer": "^0.5.8", "@brillout/json-serializer": "^0.5.8",
"@dicebear/collection": "^7.0.5", "@dicebear/collection": "^7.0.5",

View File

@ -87,7 +87,7 @@
"overrides": { "overrides": {
"vite": "$vite" "vite": "$vite"
}, },
"version": "0.41.4", "version": "0.41.5",
"imports": { "imports": {
"#/*": "./*.js" "#/*": "./*.js"
} }

View File

@ -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;
} }
const newParams = new URLSearchParams({ if (entity.affiliate?.parameters) {
...Object.fromEntries(new URL(entity.url).searchParams), const newParams = new URLSearchParams({
...Object.fromEntries(new URLSearchParams(entity.affiliate.parameters)), ...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> </script>

View File

@ -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' ? {

View File

@ -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

@ -1 +1 @@
Subproject commit d491eaf87d506618df464c87f2d2c8829e887d64 Subproject commit 1fc67541d5b45b0e20d27cd366a01f9a83e444cc