-
-
Notifications
You must be signed in to change notification settings - Fork 199
Sustainability 2025 queries #4171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sustainability 2025 queries #4171
Conversation
| FROM UNNEST(JSON_EXTRACT_ARRAY(css, '$.stylesheet.rules')) AS rule | ||
| WHERE JSON_EXTRACT_SCALAR(rule, '$.type') = 'media' AND | ||
| JSON_EXTRACT_SCALAR(rule, '$.media') = '(prefers-color-scheme:dark)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| FROM UNNEST(JSON_EXTRACT_ARRAY(css, '$.stylesheet.rules')) AS rule | |
| WHERE JSON_EXTRACT_SCALAR(rule, '$.type') = 'media' AND | |
| JSON_EXTRACT_SCALAR(rule, '$.media') = '(prefers-color-scheme:dark)' | |
| FROM UNNEST(JSON_EXTRACT_ARRAY(css.stylesheet.rules)) AS rule | |
| WHERE STRING(rule.type) = 'media' AND | |
| STRING(rule.media) = '(prefers-color-scheme:dark)' |
as we've updated css column to JSON type.
| CREATE TEMPORARY FUNCTION HASCONTENTVISIBILITY(css STRING) | ||
| RETURNS ARRAY<STRUCT<property STRING, freq INT64>> | ||
| LANGUAGE js | ||
| OPTIONS (library = "gs://httparchive/lib/css-utils.js") | ||
| AS ''' | ||
| try { | ||
| var ast = JSON.parse(css); | ||
|
|
||
| let ret = {}; | ||
|
|
||
| walkDeclarations(ast, ({property}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| CREATE TEMPORARY FUNCTION HASCONTENTVISIBILITY(css STRING) | |
| RETURNS ARRAY<STRUCT<property STRING, freq INT64>> | |
| LANGUAGE js | |
| OPTIONS (library = "gs://httparchive/lib/css-utils.js") | |
| AS ''' | |
| try { | |
| var ast = JSON.parse(css); | |
| let ret = {}; | |
| walkDeclarations(ast, ({property}) => { | |
| CREATE TEMPORARY FUNCTION HASCONTENTVISIBILITY(css JSON) | |
| RETURNS ARRAY<STRUCT<property STRING, freq INT64>> | |
| LANGUAGE js | |
| OPTIONS (library = "gs://httparchive/lib/css-utils.js") | |
| AS ''' | |
| try { | |
| let ret = {}; | |
| walkDeclarations(css, ({property}) => { |
| client, | ||
| page, | ||
| tech.technology AS ecommerce, | ||
| CAST(JSON_VALUE(summary, '$.bytesTotal') AS INT64) / 1024 AS total_kb, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| CAST(JSON_VALUE(summary, '$.bytesTotal') AS INT64) / 1024 AS total_kb, | |
| INT64(summary.bytesTotal) / 1024 AS total_kb, |
please update all the similar JSON values to this approach for readability
π Description
Working on queries for #4088.
β Migrated
The following queries have been migrated from 2024 to 2025 using the new crawl dataset: https://har.fyi/guides/migrating-to-crawl-dataset/