Skip to content

Commit

Permalink
cwv_tech_report tested
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ostapenko committed Nov 23, 2024
1 parent cc04bb6 commit 9c8e567
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions definitions/output/tech_reports/adoption.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish('adoption', {
clusterBy: ['rank', 'geo']
},
tags: ['cwv_tech_report']
}).query(ctx => `
}).preOps(`
CREATE TEMPORARY FUNCTION GET_ADOPTION(
records ARRAY<STRUCT<
client STRING,
Expand All @@ -25,7 +25,7 @@ return Object.fromEntries(
return [client, origins]
}))
''';
`).query(ctx => `
SELECT
date,
app AS technology,
Expand Down
22 changes: 11 additions & 11 deletions definitions/output/tech_reports/core_web_vitals.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish('core_web_vitals', {
clusterBy: ['rank', 'geo']
},
tags: ['cwv_tech_report']
}).query(ctx => `
}).preOps(`
CREATE TEMPORARY FUNCTION GET_VITALS(
records ARRAY<STRUCT<
client STRING,
Expand Down Expand Up @@ -39,32 +39,32 @@ RETURNS ARRAY<STRUCT<
tested INT64
>>>
LANGUAGE js AS '''
const METRIC_MAP = {{
const METRIC_MAP = {
overall: ['origins_with_good_cwv', 'origins_eligible_for_cwv'],
LCP: ['origins_with_good_lcp', 'origins_with_any_lcp'],
CLS: ['origins_with_good_cls', 'origins_with_any_cls'],
FID: ['origins_with_good_fid', 'origins_with_any_fid'],
FCP: ['origins_with_good_fcp', 'origins_with_any_fcp'],
TTFB: ['origins_with_good_ttfb', 'origins_with_any_ttfb'],
INP: ['origins_with_good_inp', 'origins_with_any_inp']
}};
};
// Initialize the vitals map.
const vitals = Object.fromEntries(
Object.keys(METRIC_MAP).map(metricName => {{
return [metricName, {{name: metricName}}]
}}));
Object.keys(METRIC_MAP).map(metricName => {
return [metricName, {name: metricName}]
}));
// Populate each client record.
records.forEach(record => {{
records.forEach(record => {
Object.entries(METRIC_MAP).forEach(
([metricName, [good_number, tested]]) => {{
vitals[metricName][record.client] = {{good_number: record[good_number], tested: record[tested]}}
}})}})
([metricName, [good_number, tested]]) => {
vitals[metricName][record.client] = {good_number: record[good_number], tested: record[tested]}
})})
return Object.values(vitals)
''';
`).query(ctx => `
SELECT
date,
app AS technology,
Expand Down
24 changes: 12 additions & 12 deletions definitions/output/tech_reports/lighthouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish('lighthouse', {
clusterBy: ['rank', 'geo']
},
tags: ['cwv_tech_report']
}).query(ctx => `
}).preOps(`
CREATE TEMPORARY FUNCTION GET_LIGHTHOUSE(
records ARRAY<STRUCT<
client STRING,
Expand All @@ -28,29 +28,29 @@ RETURNS ARRAY<STRUCT<
median_score NUMERIC
>>>
LANGUAGE js AS '''
const METRIC_MAP = {{
const METRIC_MAP = {
accessibility: 'median_lighthouse_score_accessibility',
best_practices: 'median_lighthouse_score_best_practices',
performance: 'median_lighthouse_score_performance',
pwa: 'median_lighthouse_score_pwa',
seo: 'median_lighthouse_score_seo',
}}
}
// Initialize the Lighthouse map.
const lighthouse = Object.fromEntries(Object.keys(METRIC_MAP).map(metricName => {{
return [metricName, {{name: metricName}}]
}}));
const lighthouse = Object.fromEntries(Object.keys(METRIC_MAP).map(metricName => {
return [metricName, {name: metricName}]
}));
// Populate each client record.
records.forEach(record => {{
Object.entries(METRIC_MAP).forEach(([metricName, median_score]) => {{
lighthouse[metricName][record.client] = {{median_score: record[median_score]}}
}});
}});
records.forEach(record => {
Object.entries(METRIC_MAP).forEach(([metricName, median_score]) => {
lighthouse[metricName][record.client] = {median_score: record[median_score]}
});
});
return Object.values(lighthouse)
''';
`).query(ctx => `
SELECT
date,
app AS technology,
Expand Down
20 changes: 10 additions & 10 deletions definitions/output/tech_reports/page_weight.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish('page_weight', {
clusterBy: ['rank', 'geo']
},
tags: ['cwv_tech_report']
}).query(ctx => `
}).preOps(`
CREATE TEMPORARY FUNCTION GET_PAGE_WEIGHT(
records ARRAY<STRUCT<
client STRING,
Expand All @@ -29,20 +29,20 @@ LANGUAGE js AS '''
const METRICS = ['total', 'js', 'images']
// Initialize the page weight map.
const pageWeight = Object.fromEntries(METRICS.map(metricName => {{
return [metricName, {{name: metricName}}]
}}))
const pageWeight = Object.fromEntries(METRICS.map(metricName => {
return [metricName, {name: metricName}]
}))
// Populate each client record.
records.forEach(record => {{
METRICS.forEach(metricName => {{
pageWeight[metricName][record.client] = {{median_bytes: record[metricName]}}
}})
}})
records.forEach(record => {
METRICS.forEach(metricName => {
pageWeight[metricName][record.client] = {median_bytes: record[metricName]}
})
})
return Object.values(pageWeight)
''';
`).query(ctx => `
SELECT
date,
app AS technology,
Expand Down

0 comments on commit 9c8e567

Please sign in to comment.