Skip to content

Commit

Permalink
versions table
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ostapenko committed Jan 26, 2025
1 parent bfac4f6 commit ac2f597
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 12 deletions.
21 changes: 9 additions & 12 deletions definitions/output/reports/tech_crux.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ publish('tech_crux', {
tags: ['tech_report'],
dependOnDependencyAssertions: true
}).preOps(ctx => `
--DELETE FROM ${ctx.self()}
--WHERE date = '${pastMonth}';
DELETE FROM ${ctx.self()}
WHERE date = '${pastMonth}';
CREATE TEMP FUNCTION IS_GOOD(
good FLOAT64,
Expand Down Expand Up @@ -155,8 +155,8 @@ technologies AS (
UNNEST(technologies) AS tech,
UNNEST(tech.info) AS version
WHERE
technology.technology IS NOT NULL AND
technology.technology != '' AND
tech.technology IS NOT NULL AND
tech.technology != '' AND
REGEXP_EXTRACT_ALL(version, r'(0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)')[SAFE_OFFSET(0)] IS NOT NULL
UNION ALL
Expand All @@ -168,9 +168,6 @@ technologies AS (
page
FROM pages,
UNNEST(technologies) AS tech
WHERE
technology.technology IS NOT NULL AND
technology.technology != ''
UNION ALL
Expand All @@ -184,11 +181,11 @@ technologies AS (
categories AS (
SELECT
technology.technology,
tech.technology,
ARRAY_TO_STRING(ARRAY_AGG(DISTINCT category IGNORE NULLS ORDER BY category), ', ') AS category
FROM pages,
UNNEST(technologies) AS technology,
UNNEST(technology.categories) AS category
UNNEST(technologies) AS tech,
UNNEST(tech.categories) AS category
GROUP BY technology
UNION ALL
Expand All @@ -197,8 +194,8 @@ categories AS (
'ALL' AS technology,
ARRAY_TO_STRING(ARRAY_AGG(DISTINCT category IGNORE NULLS ORDER BY category), ', ') AS category
FROM pages,
UNNEST(technologies) AS technology,
UNNEST(technology.categories) AS category
UNNEST(technologies) AS tech,
UNNEST(tech.categories) AS category
WHERE
client = 'mobile'
),
Expand Down
62 changes: 62 additions & 0 deletions definitions/output/reports/tech_report_versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const pastMonth = constants.fnPastMonth(constants.currentMonth)

publish('tech_report_versions', {
schema: 'reports',
type: 'table',
tags: ['tech_report']
}).query(ctx => `
/* {"dataform_trigger": "report_cwv_tech_complete", "name": "versions", "type": "dict"} */
WITH pages AS (
SELECT DISTINCT
client,
root_page,
tech.technology
REGEXP_EXTRACT_ALL(version, r'(0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)')[SAFE_OFFSET(0)] AS version
FROM ${ctx.ref('crawl', 'pages')},
UNNEST(technologies) AS tech
LEFT JOIN tech.info AS version
WHERE
date = '${pastMonth}'
${constants.devRankFilter}
),
version_origins AS (
SELECT
client,
technology,
version,
COUNT(DISTINCT root_page) AS origins
FROM pages
WHERE version IS NOT NULL
GROUP BY
client,
technology
),
total_origins AS (
SELECT
client,
technology,
COUNT(DISTINCT root_page) AS origins
FROM pages
GROUP BY
client,
technology
)
SELECT
client,
technology,
version,
origins
FROM version_origins
UNION ALL
SELECT
client,
technology,
'ALL' AS version,
origins
FROM total_origins
`)

0 comments on commit ac2f597

Please sign in to comment.