Skip to content

Commit 6d97a0b

Browse files
jcmpagelchristianliebel
authored andcommitted
Add SQL query for gradient adoption analysis
This SQL query analyzes the adoption of CSS gradients by clients over specific years, grouping results by rank and calculating the percentage of sites using gradients.
1 parent 3259399 commit 6d97a0b

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#standardSQL
2+
-- Adoption of CSS gradients in custom_metrics.css_variables
3+
-- Grouped by: year, client, rank bucket
4+
5+
WITH ranks AS (
6+
SELECT 1000 AS rank_grouping UNION ALL
7+
SELECT 10000 UNION ALL
8+
SELECT 100000 UNION ALL
9+
SELECT 1000000 UNION ALL
10+
SELECT 10000000 UNION ALL
11+
SELECT 100000000
12+
)
13+
14+
SELECT
15+
EXTRACT(YEAR FROM date) AS year,
16+
client,
17+
r.rank_grouping,
18+
COUNT(DISTINCT page) AS total_sites,
19+
COUNT(DISTINCT IF(
20+
REGEXP_CONTAINS(
21+
TO_JSON_STRING(custom_metrics.css_variables),
22+
r'(?i)gradient\('
23+
),
24+
page,
25+
NULL
26+
)) AS sites_using_gradient,
27+
SAFE_DIVIDE(
28+
COUNT(DISTINCT IF(
29+
REGEXP_CONTAINS(
30+
TO_JSON_STRING(custom_metrics.css_variables),
31+
r'(?i)gradient\('
32+
),
33+
page,
34+
NULL
35+
)),
36+
COUNT(DISTINCT page)
37+
) AS pct_sites_using_gradient
38+
FROM `httparchive.crawl.pages`
39+
CROSS JOIN ranks r
40+
WHERE
41+
is_root_page
42+
AND rank <= r.rank_grouping
43+
AND date IN (
44+
DATE '2019-07-01',
45+
DATE '2020-08-01',
46+
DATE '2021-07-01',
47+
DATE '2022-07-01', -- CSS metrics exception
48+
DATE '2024-06-01',
49+
DATE '2025-07-01'
50+
)
51+
GROUP BY year, client, r.rank_grouping
52+
ORDER BY year, client, r.rank_grouping;

0 commit comments

Comments
 (0)