-
-
Notifications
You must be signed in to change notification settings - Fork 209
Expand file tree
/
Copy pathfonts_designer.sql
More file actions
54 lines (50 loc) · 979 Bytes
/
fonts_designer.sql
File metadata and controls
54 lines (50 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- Section: Design
-- Question: Which designers are popular?
-- Normalization: Pages
-- INCLUDE https://github.com/HTTPArchive/almanac.httparchive.org/blob/main/sql/{year}/fonts/common.sql
WITH
designers AS (
SELECT
client,
NULLIF(TRIM(STRING(payload._font_details.names[9])), '') AS designer,
COUNT(DISTINCT page) AS count,
ROW_NUMBER() OVER (PARTITION BY client ORDER BY COUNT(DISTINCT page) DESC) AS rank
FROM
`httparchive.crawl.requests`
WHERE
date = @date AND
type = 'font' AND
is_root_page AND
IS_PARSED(payload)
GROUP BY
client,
designer
QUALIFY
rank <= 100
),
pages AS (
SELECT
client,
COUNT(DISTINCT page) AS total
FROM
`httparchive.crawl.requests`
WHERE
date = @date AND
is_root_page
GROUP BY
client
)
SELECT
client,
designer,
count,
total,
ROUND(count / total, @precision) AS proportion
FROM
designers
JOIN
pages
USING (client)
ORDER BY
client,
count DESC