Skip to content

Commit 3cefa88

Browse files
authored
Update SQL query for distinct wasm origin count
1 parent ef085c1 commit 3cefa88

1 file changed

Lines changed: 27 additions & 26 deletions

File tree

sql/2025/webassembly/counts.sql

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
# Query for wasm requests' count with distinct wasm name
1+
# Query for wasm requests' count with distinct wasm origin name
22

33
WITH wasmRequests AS (
4-
SELECT
5-
client,
6-
CASE
7-
WHEN REGEXP_CONTAINS(url, r'/(hyphenopoly|patterns).*/[a-z-]{2,5}\.wasm')
8-
THEN '(hyphenopoly dictionary)'
9-
WHEN ENDS_WITH(url, '.unityweb')
10-
THEN '(unityweb app)'
11-
ELSE
12-
REGEXP_REPLACE(
13-
REGEXP_EXTRACT(LOWER(url), r'.*/([^./?]*)'), -- lowercase & extract filename between last `/` and `.` or `?`
14-
r'-[0-9a-f]{20,32}$', -- trim trailing hashes to transform `name-0abc43234[...]` to `name`
15-
''
16-
)
17-
END AS name
18-
FROM
19-
`httparchive.crawl.requests`
20-
WHERE
21-
date = '2025-07-01' AND
22-
type = 'wasm'
4+
SELECT
5+
client,
6+
page,
7+
CASE
8+
WHEN REGEXP_CONTAINS(url, r'/(hyphenopoly|patterns).*/[a-z-]{2,5}\.wasm')
9+
THEN '(hyphenopoly dictionary)'
10+
WHEN ENDS_WITH(url, '.unityweb')
11+
THEN '(unityweb app)'
12+
ELSE
13+
REGEXP_REPLACE(
14+
REGEXP_EXTRACT(LOWER(url), r'./([^./?])'), -- lowercase & extract filename between last `/` and `.` or `?`
15+
r'-[0-9a-f]{20,32}$', -- trim trailing hashes to transform `name-0abc43234[...]` to `name`
16+
''
17+
)
18+
END AS name
19+
FROM
20+
`httparchive.crawl.requests`
21+
WHERE
22+
date = '2025-07-01' AND
23+
type = 'wasm'
2324
)
2425

2526
SELECT
26-
client,
27-
COUNT(0) AS total_wasm,
28-
COUNT(DISTINCT name) AS total_distinct_wasm
27+
client,
28+
COUNT(0) AS total_wasm,
29+
COUNT(DISTINCT NET.REG_DOMAIN(page)) AS distinct_origin
2930
FROM
30-
wasmRequests
31+
wasmRequests
3132
GROUP BY
32-
client
33+
client
3334
ORDER BY
34-
client
35+
client

0 commit comments

Comments
 (0)