Skip to content

Commit

Permalink
dataset change
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ostapenko committed Nov 23, 2024
1 parent 4c361a9 commit cc04bb6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 35 deletions.
9 changes: 4 additions & 5 deletions definitions/output/tech_reports/adoption.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const pastMonth = constants.fnPastMonth(constants.currentMonth)

publish('adoption', {
schema: 'tech_reports',
schema: 'cwv_tech_reports',
type: 'incremental',
protected: true,
bigquery: {
Expand All @@ -21,10 +21,9 @@ RETURNS STRUCT<
>
LANGUAGE js AS '''
return Object.fromEntries(
records.map(({{client, origins}}) => {{
return [client, origins];
}})
);
records.map(({client, origins}) => {
return [client, origins]
}))
''';
SELECT
Expand Down
2 changes: 1 addition & 1 deletion definitions/output/tech_reports/categories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const pastMonth = constants.fnPastMonth(constants.currentMonth)

publish('categories', {
schema: 'tech_reports',
schema: 'cwv_tech_reports',
type: 'table',
tags: ['cwv_tech_report']
}).query(ctx => `
Expand Down
15 changes: 6 additions & 9 deletions definitions/output/tech_reports/core_web_vitals.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const pastMonth = constants.fnPastMonth(constants.currentMonth)

publish('core_web_vitals', {
schema: 'tech_reports',
schema: 'cwv_tech_reports',
type: 'incremental',
protected: true,
bigquery: {
Expand Down Expand Up @@ -52,20 +52,17 @@ const METRIC_MAP = {{
// Initialize the vitals map.
const vitals = Object.fromEntries(
Object.keys(METRIC_MAP).map(metricName => {{
return [metricName, {{name: metricName}}];
}})
);
return [metricName, {{name: metricName}}]
}}));
// Populate each client 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]}};
}}
);
}});
vitals[metricName][record.client] = {{good_number: record[good_number], tested: record[tested]}}
}})}})
return Object.values(vitals);
return Object.values(vitals)
''';
SELECT
Expand Down
16 changes: 7 additions & 9 deletions definitions/output/tech_reports/lighthouse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const pastMonth = constants.fnPastMonth(constants.currentMonth)

publish('lighthouse', {
schema: 'tech_reports',
schema: 'cwv_tech_reports',
type: 'incremental',
protected: true,
bigquery: {
Expand Down Expand Up @@ -34,23 +34,21 @@ const METRIC_MAP = {{
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]}};
lighthouse[metricName][record.client] = {{median_score: record[median_score]}}
}});
}});
return Object.values(lighthouse);
return Object.values(lighthouse)
''';
SELECT
Expand Down
18 changes: 8 additions & 10 deletions definitions/output/tech_reports/page_weight.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const pastMonth = constants.fnPastMonth(constants.currentMonth)

publish('page_weight', {
schema: 'tech_reports',
schema: 'cwv_tech_reports',
type: 'incremental',
protected: true,
bigquery: {
Expand All @@ -26,21 +26,19 @@ RETURNS ARRAY<STRUCT<
median_bytes INT64
>>>
LANGUAGE js AS '''
const METRICS = ['total', 'js', 'images'];
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]}};
}});
}});
pageWeight[metricName][record.client] = {{median_bytes: record[metricName]}}
}})
}})
return Object.values(pageWeight)
''';
Expand Down
2 changes: 1 addition & 1 deletion definitions/output/tech_reports/technologies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const pastMonth = constants.fnPastMonth(constants.currentMonth)

publish('technologies', {
schema: 'tech_reports',
schema: 'cwv_tech_reports',
type: 'table',
tags: ['cwv_tech_report']
}).query(ctx => `
Expand Down

0 comments on commit cc04bb6

Please sign in to comment.