Skip to content

Commit

Permalink
include beta collection types in ad placement logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cemms1 committed Dec 3, 2024
1 parent e1b58b3 commit 2ca8b24
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dotcom-rendering/src/lib/getFrontsAdPositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type GroupedCounts = {
veryBig: number;
big: number;
standard: number;
splash: number;
};

type AdCandidate = Pick<DCRCollectionType, 'collectionType'>;
Expand Down Expand Up @@ -95,18 +96,22 @@ const getCollectionHeight = (
veryBig: grouped.veryBig.length,
big: grouped.big.length,
standard: grouped.standard.length,
splash: grouped.splash.length,
};

switch (collectionType) {
// Some thrashers are very small. Since we'd prefer to have ads above content rather than thrashers,
// err on the side of inserting fewer ads, by setting the number on the small side for thrashers
case 'fixed/thrasher':
case 'scrollable/small':
return 0.5;

case 'fixed/small/slow-IV':
case 'fixed/small/slow-V-mpu':
case 'nav/list':
case 'nav/media-list':
case 'scrollable/medium':
case 'static/medium/4':
return 1;

case 'fixed/small/slow-I':
Expand All @@ -116,13 +121,15 @@ const getCollectionHeight = (
case 'fixed/small/fast-VIII':
case 'fixed/video':
case 'fixed/video/vertical':
case 'scrollable/feature':
return 1.5;

case 'fixed/medium/slow-VI':
case 'fixed/medium/slow-VII':
case 'fixed/medium/slow-XII-mpu':
case 'fixed/medium/fast-XI':
case 'fixed/medium/fast-XII':
case 'static/feature/2':
return 2;

case 'fixed/large/slow-XIV':
Expand Down Expand Up @@ -157,6 +164,24 @@ const getCollectionHeight = (
}
return 1;

case 'flexible/special':
if (groupedCounts.snap && !groupedCounts.splash) {
return 1.5;
} else if (groupedCounts.splash && !groupedCounts.standard) {
return 2.5;
} else {
return 3;
}

case 'flexible/general':
if (groupedCounts.splash && !groupedCounts.standard) {
return 2;
} else if (groupedCounts.splash && groupedCounts.standard > 2) {
return 3;
} else {
return 2.5;
}

default:
return 1; // Unknown collection type.
}
Expand Down

0 comments on commit 2ca8b24

Please sign in to comment.