Skip to content

Commit

Permalink
fix: new rum checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
alinarublea committed Dec 20, 2024
1 parent 3fc6dd6 commit c27d9ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function handler(bundles) {
? bundle.weight
: 0));
const totalPageViews = dataChunks?.totals?.traffic_domain?.weight;
const totalCTR = dataChunks?.totals?.ctr?.sum / dataChunks?.totals?.ctr?.weight;
const sum = dataChunks?.totals?.ctr?.sum ?? 0;
const weight = dataChunks?.totals?.ctr?.weight ?? 0;
const totalCTR = weight !== 0 ? sum / weight : 0;
return {
totalPageViews,
totalCTR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Total Metrics Queries', () => {
it('crunches CWV data', async () => {
const result = totalMetrics.handler(bundlesForUrls.rumBundles);
expect(result).to.deep.equal({
totalCTR: 7303,
totalCTR: 0.2027468663384768,
totalPageViews: 24173,
});
});
Expand Down

0 comments on commit c27d9ef

Please sign in to comment.