Skip to content

Commit e299642

Browse files
jcmpagelchristianliebel
authored andcommitted
Add SQL script for analyzing web page platforms
1 parent 12c22ca commit e299642

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#standardSQL
2+
WITH base AS (
3+
SELECT
4+
date,
5+
page,
6+
NET.HOST(page) AS host
7+
FROM
8+
`httparchive.crawl.pages`
9+
WHERE
10+
client = 'desktop'
11+
AND is_root_page
12+
AND date IN (
13+
'2020-01-01','2020-04-01','2020-07-01','2020-10-01',
14+
'2021-01-01','2021-04-01','2021-07-01','2021-10-01',
15+
'2022-01-01','2022-04-01','2022-07-01','2022-10-01',
16+
'2023-01-01','2023-04-01','2023-07-01','2023-10-01',
17+
'2024-01-01','2024-04-01','2024-07-01','2024-10-01',
18+
'2025-01-01','2025-04-01','2025-07-01','2025-10-01'
19+
)
20+
),
21+
22+
classified AS (
23+
SELECT
24+
date,
25+
page,
26+
CASE
27+
WHEN ENDS_WITH(host, 'vercel.app') THEN 'vercel'
28+
WHEN ENDS_WITH(host, 'pages.dev') THEN 'cloudflare_pages'
29+
WHEN ENDS_WITH(host, 'workers.dev') THEN 'cloudflare_workers'
30+
WHEN ENDS_WITH(host, 'lovable.app') OR ENDS_WITH(host, 'lovable.dev') THEN 'lovable'
31+
WHEN ENDS_WITH(host, 'bolt.new') OR ENDS_WITH(host, 'stackblitz.io') THEN 'bolt'
32+
WHEN ENDS_WITH(host, 'v0.dev') THEN 'v0'
33+
WHEN ENDS_WITH(host, 'replit.app') THEN 'replit'
34+
ELSE NULL
35+
END AS platform
36+
FROM
37+
base
38+
),
39+
40+
totals AS (
41+
SELECT
42+
date,
43+
COUNT(0) AS total_pages
44+
FROM
45+
base
46+
GROUP BY
47+
date
48+
)
49+
50+
SELECT
51+
c.date,
52+
c.platform,
53+
COUNT(0) AS pages,
54+
SAFE_DIVIDE(COUNT(0), t.total_pages) AS pct_pages
55+
FROM
56+
classified c
57+
JOIN
58+
totals t
59+
USING (date)
60+
WHERE
61+
c.platform IS NOT NULL
62+
GROUP BY
63+
c.date,
64+
c.platform,
65+
t.total_pages
66+
ORDER BY
67+
c.date,
68+
pct_pages DESC;

0 commit comments

Comments
 (0)