Skip to content

Commit

Permalink
by client
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ostapenko committed Jan 12, 2025
1 parent 93ea0f6 commit d6fea3a
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions definitions/output/reports/cwv_tech_categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,49 @@ publish('cwv_tech_categories', {
/* {"dataform_trigger": "report_cwv_tech_complete", "name": "categories", "type": "dict"} */
WITH pages AS (
SELECT
root_page,
client,
root_page AS origin,
technologies
FROM ${ctx.ref('crawl', 'pages')}
WHERE
date = '${pastMonth}' AND
client = 'mobile'
date = '${pastMonth}'
${constants.devRankFilter}
), categories AS (
SELECT
client,
category,
COUNT(DISTINCT root_page) AS origins
COUNT(DISTINCT origin) AS origins
FROM pages,
UNNEST(technologies) AS t,
UNNEST(t.categories) AS category
GROUP BY category
UNNEST(technologies) AS tech,
UNNEST(tech.categories) AS category
GROUP BY
client,
category
), technologies AS (
SELECT
client,
category,
technology,
COUNT(DISTINCT root_page) AS origins
COUNT(DISTINCT origin) AS origins
FROM pages,
UNNEST(technologies) AS t,
UNNEST(t.categories) AS category
UNNEST(technologies) AS tech,
UNNEST(tech.categories) AS category
GROUP BY
client,
category,
technology
)
SELECT
client,
category,
categories.origins,
ARRAY_AGG(technology IGNORE NULLS ORDER BY technologies.origins DESC) AS technologies
FROM categories
JOIN technologies
INNER JOIN technologies
USING (category)
GROUP BY
client,
category,
categories.origins
ORDER BY categories.origins DESC
Expand Down

0 comments on commit d6fea3a

Please sign in to comment.