-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfac4f6
commit ac2f597
Showing
2 changed files
with
71 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
`) |