Last active
June 26, 2019 12:24
-
-
Save tjmonsi/01511617cbaea6954d62256e920a1d26 to your computer and use it in GitHub Desktop.
Counts the sites that delivers hosted fonts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#standardSQL | |
-- counts the host_url of a given font | |
WITH | |
summary_pages AS ( | |
SELECT * FROM `httparchive.sample_data.summary_pages_desktop_1k` | |
UNION ALL | |
SELECT * FROM `httparchive.sample_data.summary_pages_mobile_1k` | |
), | |
summary_requests AS ( | |
SELECT * FROM `httparchive.sample_data.summary_requests_desktop_1k` | |
UNION ALL | |
SELECT * FROM `httparchive.sample_data.summary_requests_mobile_1k` | |
), | |
merge_table AS ( | |
SELECT * FROM summary_requests JOIN ( | |
SELECT pageid, url AS page_url FROM summary_pages | |
) USING (pageid) | |
), | |
processedTable AS ( | |
SELECT (NET.HOST(url) != NET.HOST(page_url)) as hosted, url, page_url | |
FROM merge_table WHERE type = 'font' | |
) | |
SELECT value AS host, count | |
FROM ( | |
SELECT APPROX_TOP_COUNT(NET.HOST(url), 500) AS font_host | |
FROM processedTable | |
WHERE hosted = true | |
), UNNEST(font_host) |
Wow, i made a lot more hehe... But thanks for this :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can modify this query to handle other metrics, like find the top 25 font formats by querying the
ext
field: