Skip to content

Commit

Permalink
Merge branch 'main' into lp-remove-front-containers-for-us-aus
Browse files Browse the repository at this point in the history
  • Loading branch information
LAKSHMIRPILLAI authored Jan 8, 2025
2 parents c72de0b + f244edb commit 64ec9a5
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# All rendering apps deployment
- name: Upload rendering apps to RiffRaff
uses: guardian/actions-riff-raff@v4
uses: guardian/actions-riff-raff@v4.1.2
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
roleArn: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@guardian/bridget": "8.1.0",
"@guardian/browserslist-config": "6.1.0",
"@guardian/cdk": "50.13.0",
"@guardian/commercial": "23.7.4",
"@guardian/commercial": "24.0.0",
"@guardian/core-web-vitals": "7.0.0",
"@guardian/eslint-config": "7.0.1",
"@guardian/eslint-config-typescript": "9.0.1",
Expand Down
33 changes: 32 additions & 1 deletion 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 @@ -75,13 +76,14 @@ const getMobileAdPositions = (collections: AdCandidate[]): number[] => {
*
* A result of 3 would approximately be the height of a typical desktop viewport (~900px).
* A result of 1 would be a third of the height, a result of 1.5 would be half, etc.
* A result of 6 indicates a container is at least double the height of a typical desktop viewport.
*/
const getCollectionHeight = (
collction: Pick<
DCRCollectionType,
'collectionType' | 'containerPalette' | 'grouped'
>,
): 0.5 | 1 | 1.5 | 2 | 2.5 | 3 => {
): 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 6 => {
const { collectionType, containerPalette, grouped } = collction;

if (containerPalette === 'PodcastPalette') {
Expand All @@ -95,18 +97,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 +122,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 +165,29 @@ 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.5;
} else if (groupedCounts.splash && groupedCounts.standard > 2) {
return 6;
} else if (
grouped.splash[0]?.boostLevel === 'megaboost' ||
grouped.splash[0]?.boostLevel === 'gigaboost'
) {
return 6;
} else {
return 3;
}

default:
return 1; // Unknown collection type.
}
Expand Down
76 changes: 42 additions & 34 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 64ec9a5

Please sign in to comment.