Expanded and improved campaigns.

This commit is contained in:
DebaucheryLibrarian 2024-06-13 02:26:34 +02:00
parent 41d6324c28
commit 22e0a331a3
6 changed files with 13 additions and 12 deletions

View File

@ -451,7 +451,7 @@ function toggleFilters(state) {
display: flex;
&.close {
background: var(--grey-light-40);
background: var(--background-base-20);
position: relative;
right: 0;
}

View File

@ -119,6 +119,7 @@ const scrollable = computed(() => children.value?.scrollWidth > children.value?.
.page {
display: flex;
flex-direction: column;
flex-grow: 1;
}
.content {

View File

@ -45,7 +45,7 @@ export async function onBeforeRender(pageContext) {
parentEntityId: entity.parent?.id,
minRatio: 1.5,
},
]);
], { tagFilter: pageContext.tagFilter });
const {
scenes,

View File

@ -23,7 +23,7 @@ export async function onBeforeRender(pageContext) {
{ minRatio: 1.5 },
{ minRatio: 0.75, maxRatio: 1.25 },
{ minRatio: 1.5 },
]),
], { tagFilter: pageContext.tagFilter }),
]);
const {

View File

@ -23,11 +23,7 @@ function curateCampaign(campaign) {
height: campaign.banner.height,
ratio: campaign.banner.ratio,
entity: campaign.banner_entity && curateEntity({ ...campaign.banner_entity, parent: campaign.banner_parent_entity }),
tags: campaign.banner_tags?.map((tag) => ({
id: tag.id,
slug: tag.slug,
name: tag.name,
})) || [],
tags: campaign.banner_tags || [],
},
affiliate: campaign.affiliate && {
id: campaign.affiliate.id,
@ -37,7 +33,7 @@ function curateCampaign(campaign) {
};
}
export async function getRandomCampaign(options = {}) {
export async function getRandomCampaign(options = {}, context = {}) {
const campaigns = options.campaigns
|| await redis.hGetAll('traxxx:campaigns').then((rawCampaigns) => Object.values(rawCampaigns).map((rawCampaign) => JSON.parse(rawCampaign)));
@ -54,6 +50,10 @@ export async function getRandomCampaign(options = {}) {
return false;
}
if (context.tagFilter && campaign.banner && campaign.banner.tags.some((tag) => context.tagFilter.includes(tag))) {
return false;
}
return true;
});
@ -70,14 +70,14 @@ export async function getRandomCampaign(options = {}) {
return null;
}
export async function getRandomCampaigns(allOptions = []) {
export async function getRandomCampaigns(allOptions = [], context = {}) {
const rawCampaigns = await redis.hGetAll('traxxx:campaigns');
const campaigns = Object.values(rawCampaigns).map((rawCampaign) => JSON.parse(rawCampaign));
return Promise.all(allOptions.map(async (options) => getRandomCampaign({
...options,
campaigns,
})));
}, context)));
}
export async function cacheCampaigns() {

2
static

@ -1 +1 @@
Subproject commit 24d11363ef7632591ec6f49240079259f777ab9e
Subproject commit 6289c5ff5707aac96d306f29805c322393164d3a