Skip to content

Commit a8363d5

Browse files
Capabilities Queries for 2024 (#3747)
* Capabilities Queries for 2024 * update the queries * fix linting? * Handle secondary pages --------- Co-authored-by: Barry Pollard <[email protected]>
1 parent d1b3663 commit a8363d5

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

sql/2024/capabilities/fugu.sql

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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;

sql/2024/capabilities/top.sql

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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;

0 commit comments

Comments
 (0)