Created
October 15, 2021 20:45
-
-
Save adamsilverstein/c49fbcd2a99c74a1264c2b4c48b2e504 to your computer and use it in GitHub Desktop.
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
| CREATE TEMP FUNCTION IS_GOOD(good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( | |
| good / (good + needs_improvement + poor) >= 0.75 | |
| ); | |
| CREATE TEMP FUNCTION IS_NON_ZERO(good FLOAT64, needs_improvement FLOAT64, poor FLOAT64) RETURNS BOOL AS ( | |
| good + needs_improvement + poor > 0 | |
| ); | |
| SELECT * | |
| FROM ( | |
| SELECT | |
| date, | |
| ARRAY_TO_STRING(ARRAY_AGG(DISTINCT category IGNORE NULLS ORDER BY category), ', ') AS categories, | |
| app, | |
| info, | |
| REGEXP_EXTRACT( info, "(\\d.\\d).*" ) AS major_version, | |
| client, | |
| COUNT(DISTINCT url) AS origins, | |
| COUNT(DISTINCT IF(good_fid, url, NULL)) AS origins_with_good_fid, | |
| COUNT(DISTINCT IF(good_cls, url, NULL)) AS origins_with_good_cls, | |
| COUNT(DISTINCT IF(good_lcp, url, NULL)) AS origins_with_good_lcp, | |
| COUNT(DISTINCT IF(any_fid, url, NULL)) AS origins_with_any_fid, | |
| COUNT(DISTINCT IF(any_cls, url, NULL)) AS origins_with_any_cls, | |
| COUNT(DISTINCT IF(any_lcp, url, NULL)) AS origins_with_any_lcp, | |
| COUNT(DISTINCT IF(good_cwv, url, NULL)) AS origins_with_good_cwv, | |
| COUNT(DISTINCT IF(any_lcp AND any_cls, url, NULL)) AS origins_eligible_for_cwv, | |
| SAFE_DIVIDE(COUNTIF(good_cwv), COUNTIF(any_lcp AND any_cls)) AS pct_eligible_origins_with_good_cwv | |
| FROM ( | |
| SELECT | |
| date, | |
| CONCAT(origin, '/') AS url, | |
| IF(device = 'desktop', 'desktop', 'mobile') AS client, | |
| IS_NON_ZERO(fast_fid, avg_fid, slow_fid) AS any_fid, | |
| IS_GOOD(fast_fid, avg_fid, slow_fid) AS good_fid, | |
| IS_NON_ZERO(small_cls, medium_cls, large_cls) AS any_cls, | |
| IS_GOOD(small_cls, medium_cls, large_cls) AS good_cls, | |
| IS_NON_ZERO(fast_lcp, avg_lcp, slow_lcp) AS any_lcp, | |
| IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AS good_lcp, | |
| (IS_GOOD(fast_fid, avg_fid, slow_fid) OR fast_fid IS NULL) AND | |
| IS_GOOD(small_cls, medium_cls, large_cls) AND | |
| IS_GOOD(fast_lcp, avg_lcp, slow_lcp) AS good_cwv | |
| FROM | |
| `chrome-ux-report.materialized.device_summary` | |
| WHERE | |
| date = '2021-08-01' AND | |
| device IN ('desktop', 'phone') | |
| ) JOIN ( | |
| SELECT DISTINCT | |
| CAST('2021-08-01' AS DATE) AS date, | |
| category, | |
| app, | |
| info, | |
| _TABLE_SUFFIX AS client, | |
| url | |
| FROM | |
| `httparchive.technologies.2021_08_01_*` | |
| WHERE | |
| app = 'WordPress' | |
| AND info != '' | |
| ) USING (date, url, client) | |
| GROUP BY | |
| date, | |
| major_version, | |
| app, | |
| info, | |
| client | |
| ) WHERE origins > 100 | |
| ORDER BY major_version DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment