Compare commits
No commits in common. "64bf3b65ac6b4a5d3bbbcaa9f77dc9b0e3d23b77" and "7808a3e059bbd08d82d3f2ef976ebbd73efbd83f" have entirely different histories.
64bf3b65ac
...
7808a3e059
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"name": "traxxx-web",
|
||||
"version": "0.25.3",
|
||||
"version": "0.25.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "0.25.3",
|
||||
"version": "0.25.2",
|
||||
"dependencies": {
|
||||
"@brillout/json-serializer": "^0.5.8",
|
||||
"@dicebear/collection": "^7.0.5",
|
||||
|
|
|
@ -77,5 +77,5 @@
|
|||
"postcss-custom-media": "^10.0.2",
|
||||
"postcss-nesting": "^12.0.2"
|
||||
},
|
||||
"version": "0.25.3"
|
||||
"version": "0.25.2"
|
||||
}
|
||||
|
|
|
@ -57,25 +57,25 @@ export async function getRandomCampaign(options = {}, context = {}) {
|
|||
return true;
|
||||
});
|
||||
|
||||
const campaignsByEntityId = validCampaigns.reduce((acc, campaign) => {
|
||||
const entityId = campaign.entity.parent?.id || campaign.entity.id;
|
||||
|
||||
if (!acc[entityId]) {
|
||||
acc[entityId] = [];
|
||||
}
|
||||
|
||||
acc[entityId].push(campaign);
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// randomize entities first to ensure fair exposure for entities with fewer banners
|
||||
const entityIds = Object.keys(campaignsByEntityId);
|
||||
const randomEntityCampaigns = campaignsByEntityId[entityIds[crypto.randomInt(entityIds.length)]];
|
||||
|
||||
const primaryCampaigns = randomEntityCampaigns.filter((campaign) => campaign.entity.id === options.entityIds?.[0]);
|
||||
|
||||
if (validCampaigns.length > 0) {
|
||||
const campaignsByEntityId = validCampaigns.reduce((acc, campaign) => {
|
||||
const entityId = campaign.entity.parent?.id || campaign.entity.id;
|
||||
|
||||
if (!acc[entityId]) {
|
||||
acc[entityId] = [];
|
||||
}
|
||||
|
||||
acc[entityId].push(campaign);
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// randomize entities first to ensure fair exposure for entities with fewer banners
|
||||
const entityIds = Object.keys(campaignsByEntityId);
|
||||
const randomEntityCampaigns = campaignsByEntityId[entityIds[crypto.randomInt(entityIds.length)]];
|
||||
|
||||
const primaryCampaigns = randomEntityCampaigns.filter((campaign) => campaign.entity.id === options.entityIds?.[0]);
|
||||
|
||||
const randomCampaign = (primaryCampaigns.length > 0 ? primaryCampaigns[crypto.randomInt(primaryCampaigns.length)] : null)
|
||||
|| (randomEntityCampaigns.length > 0 ? randomEntityCampaigns[crypto.randomInt(randomEntityCampaigns.length)] : null)
|
||||
|| validCampaigns[crypto.randomInt(validCampaigns.length)];
|
||||
|
|
Loading…
Reference in New Issue