@@ -7,53 +7,69 @@ publish('cwv_tech_categories', {
7
7
} ) . query ( ctx => `
8
8
/* {"dataform_trigger": "report_cwv_tech_complete", "name": "categories", "type": "dict"} */
9
9
WITH pages AS (
10
- SELECT
10
+ SELECT DISTINCT
11
+ client,
11
12
root_page,
12
13
technologies
13
14
FROM ${ ctx . ref ( 'crawl' , 'pages' ) }
14
15
WHERE
15
- date = '${ pastMonth } ' AND
16
- client = 'mobile'
16
+ date = '${ pastMonth } '
17
17
${ constants . devRankFilter }
18
- ), categories AS (
18
+ ),
19
+
20
+ category_descriptions AS (
19
21
SELECT
20
22
name AS category,
21
23
description
22
24
FROM ${ ctx . ref ( 'wappalyzer' , 'categories' ) }
23
- ), category_stats AS (
25
+ ),
26
+
27
+ category_stats AS (
24
28
SELECT
25
29
category,
26
- COUNT(DISTINCT root_page) AS origins
27
- FROM pages,
28
- UNNEST(technologies) AS t,
29
- UNNEST(t.categories) AS category
30
+ STRUCT(
31
+ COALESCE(MAX(IF(client = 'desktop', origins, 0))) AS desktop,
32
+ COALESCE(MAX(IF(client = 'mobile', origins, 0))) AS mobile
33
+ ) AS origins
34
+ FROM (
35
+ SELECT
36
+ client,
37
+ category,
38
+ COUNT(DISTINCT root_page) AS origins
39
+ FROM pages
40
+ LEFT JOIN pages.technologies AS tech
41
+ LEFT JOIN tech.categories AS category
42
+ GROUP BY
43
+ client,
44
+ category
45
+ )
30
46
GROUP BY category
31
- ), technology_stats AS (
47
+ ),
48
+
49
+ technology_stats AS (
32
50
SELECT
33
- category,
34
51
technology,
35
- COUNT(DISTINCT root_page) AS origins
36
- FROM pages,
37
- UNNEST(technologies) AS t,
38
- UNNEST(t.categories) AS category
52
+ category_obj AS categories,
53
+ SUM(origins) AS total_origins
54
+ FROM ${ ctx . ref ( 'reports' , 'cwv_tech_technologies' ) }
39
55
GROUP BY
40
- category ,
41
- technology
56
+ technology ,
57
+ categories
42
58
)
43
59
44
60
SELECT
45
61
category,
46
62
description,
47
- category_stats. origins,
48
- ARRAY_AGG(technology IGNORE NULLS ORDER BY technology_stats.origins DESC) AS technologies
63
+ origins,
64
+ ARRAY_AGG(technology IGNORE NULLS ORDER BY technology_stats.total_origins DESC) AS technologies
49
65
FROM category_stats
50
66
INNER JOIN technology_stats
51
- USING ( category)
52
- LEFT JOIN categories
67
+ ON category_stats. category IN UNNEST(technology_stats.categories )
68
+ INNER JOIN category_descriptions
53
69
USING (category)
54
70
GROUP BY
55
71
category,
56
72
description,
57
73
origins
58
- ORDER BY origins DESC
74
+ ORDER BY category ASC
59
75
` )
0 commit comments