Skip to content

Commit bc3374c

Browse files
technology_matrix moved from scheduled queries (#64)
* migrated from scheduled queries * cleanup
1 parent cdf8174 commit bc3374c

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
publish('technology_matrix', {
2+
type: 'table',
3+
schema: 'core_web_vitals',
4+
bigquery: {
5+
partitionBy: 'date',
6+
clusterBy: ['client', 't1']
7+
},
8+
description: 'Used in: https://lookerstudio.google.com/u/2/reporting/0ad64c8f-644a-40f9-93e4-0ccd5f72b33d',
9+
tags: ['crawl_complete']
10+
}).query(ctx => `
11+
WITH a AS (
12+
SELECT
13+
date,
14+
client,
15+
root_page,
16+
technology AS t1,
17+
ARRAY_TO_STRING(ARRAY(SELECT category FROM UNNEST(categories) AS category ORDER BY category), ', ') AS c1
18+
FROM ${ctx.ref('crawl', 'pages')},
19+
UNNEST(technologies)
20+
WHERE
21+
date = '${constants.currentMonth}' AND
22+
is_root_page
23+
), b AS (
24+
SELECT
25+
client,
26+
root_page,
27+
technology AS t2,
28+
ARRAY_TO_STRING(ARRAY(SELECT category FROM UNNEST(categories) AS category ORDER BY category), ', ') AS c2
29+
FROM ${ctx.ref('crawl', 'pages')},
30+
UNNEST(technologies)
31+
WHERE
32+
date = '${constants.currentMonth}' AND
33+
is_root_page
34+
)
35+
36+
37+
SELECT
38+
date,
39+
client,
40+
t1,
41+
c1,
42+
t2,
43+
c2,
44+
COUNT(DISTINCT root_page) AS pages
45+
FROM a
46+
LEFT JOIN b
47+
USING (client, root_page)
48+
GROUP BY
49+
date,
50+
client,
51+
t1,
52+
c1,
53+
t2,
54+
c2
55+
`)

0 commit comments

Comments
 (0)