File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # standardSQL
2+ CREATE TEMP FUNCTION getFuguAPIs(data STRING)
3+ RETURNS ARRAY< STRING>
4+ LANGUAGE js AS ' ' '
5+ const $ = JSON.parse(data);
6+ return Object.keys($);
7+ ' ' ' ;
8+
9+ WITH fuguapis AS (
10+ SELECT
11+ date ,
12+ client,
13+ root_page,
14+ page,
15+ fuguAPI
16+ FROM
17+ ` httparchive.all.pages` ,
18+ UNNEST(getFuguAPIs(JSON_QUERY(custom_metrics, ' $."fugu-apis"' ))) AS fuguAPI
19+ WHERE
20+ date = ' 2024-06-01' AND
21+ JSON_QUERY(custom_metrics, ' $."fugu-apis"' ) != ' []'
22+ ),
23+
24+ totals AS (
25+ SELECT
26+ date ,
27+ client,
28+ COUNT (0 ) AS total
29+ FROM
30+ ` httparchive.all.pages`
31+ WHERE
32+ date = ' 2024-06-01' AND
33+ is_root_page
34+ GROUP BY
35+ date ,
36+ client
37+ )
38+
39+ SELECT
40+ client,
41+ fuguAPI,
42+ COUNT (DISTINCT root_page) AS pages,
43+ total,
44+ COUNT (DISTINCT root_page) / total AS pct,
45+ ARRAY_TO_STRING(ARRAY_AGG(DISTINCT page LIMIT 50 ), ' ' ) AS sample_urls
46+ FROM
47+ fuguapis
48+ JOIN
49+ totals
50+ USING
51+ (client, date )
52+ GROUP BY
53+ fuguAPI,
54+ client,
55+ total
56+ HAVING
57+ COUNT (DISTINCT root_page) >= 10
58+ ORDER BY
59+ pct DESC ,
60+ client;
Original file line number Diff line number Diff line change 1+ # standardSQL
2+ CREATE TEMP FUNCTION getFuguAPIs(data STRING)
3+ RETURNS ARRAY< STRING>
4+ LANGUAGE js AS ' ' '
5+ const $ = JSON.parse(data);
6+ return Object.keys($);
7+ ' ' ' ;
8+
9+ SELECT
10+ client,
11+ is_root_page,
12+ page,
13+ COUNT (DISTINCT fuguAPI) AS fuguAPIs
14+ FROM
15+ ` httparchive.all.pages` ,
16+ UNNEST(getFuguAPIs(JSON_QUERY(custom_metrics, ' $."fugu-apis"' ))) AS fuguAPI
17+ WHERE
18+ date = ' 2024-06-01' AND
19+ JSON_QUERY(custom_metrics, ' $."fugu-apis"' ) != ' []'
20+ GROUP BY
21+ client,
22+ is_root_page,
23+ page
24+ HAVING
25+ COUNT (DISTINCT fuguAPI) >= 1
26+ ORDER BY
27+ fuguAPIs DESC ,
28+ page,
29+ client
30+ LIMIT 200 ;
You can’t perform that action at this time.
0 commit comments