Skip to content

Commit 5bdb523

Browse files
mgiffordtunethewebmax-ostapenko
authored
Accessibility 2024: Queries (#3749)
* Create a11y_overall_tech_usage_by_domain_rank.sql This code was developed by Barry Pollard while he was showing me the ropes. * Update a11y_overall_tech_usage_by_domain_rank.sql Attempting to fix lint errors * Create a11y_technology_usage.sql This seems to work. * Create a11y_technology_usage_by_domain_rank.sql Seems to work.... * Update a11y_technology_usage.sql Remove white space * Create alt_ending_in_image_extension.sql Seems to work.... * Create anchors_with_role_button.sql Looks good against rank 1000 * Create audio_track_usage.sql Produces results.... * Create button_name_sources.sql Data looks good * Create captcha_usage.sql Working... * Create color_contrast.sql I'm guessing that the JSON_VALUE is the same as JSON_EXTRACT_SCALAR * Create common_alt_text_length.sql Seems to work.. * Create common_aria_role.sql * Create common_element_attributes.sql Looks good.. * Create form_input_name_sources.sql Seems to work. * Create form_required_controls.sql Seems to work. * Update a11y_overall_tech_usage_by_domain_rank.sql Incorrect spacing. * Update alt_ending_in_image_extension.sql Spacing... * Update button_name_sources.sql Spacing. * Create landmark_elements_and_roles.sql Seems to work * Create page_title.sql Seems to work * Create pages_with_search_input.sql working... * Create placeholder_but_no_label.sql Working * Create sites_using_role.sql updated.... * Create skip_links.sql updated.. * Create sr_only_classes.sql I think this probably could be extended to include other screen reader classes which are common. * Create tabindex_usage_and_values.sql Updated. * Create table_stats.sql Updated * Create valid_html_lang.sql working... * Create video_track_usage.sql * Create viewport_zoom_scale.sql working.. * Create viewport_zoom_scale_by_domain_rank.sql done * Update sql/2024/accessibility/a11y_technology_usage_by_domain_rank.sql Thanks! Co-authored-by: Barry Pollard <barrypollard@google.com> * Update sql/2024/accessibility/alt_ending_in_image_extension.sql Thanks. Co-authored-by: Barry Pollard <barrypollard@google.com> * Update viewport_zoom_scale_by_domain_rank.sql removing white space * Create lighthouse_a11y_audits.sql Thanks to @tunetheweb in Slack. Modified to make it not for testing purposes. * Create lighthouse_a11y_score.sql I think this works... * Update video_track_usage.sql Fixing spacing * Update a11y_overall_tech_usage_by_domain_rank.sql Including is_root_page in query. * Update a11y_technology_usage.sql adding is_root_page * Update a11y_technology_usage_by_domain_rank.sql * Update alt_ending_in_image_extension.sql adding is_root_page * Update anchors_with_role_button.sql * Update audio_track_usage.sql is_root_page * Update button_name_sources.sql is_root_page, * Update captcha_usage.sql is_root_page * Update color_contrast.sql is_root_page * Update common_alt_text_length.sql is_root_page * Update common_aria_role.sql is_root_page * Update common_element_attributes.sql is_root_page * Update form_input_name_sources.sql is_root_page * Update form_required_controls.sql is_root_page * Update landmark_elements_and_roles.sql is_root_page * Update lighthouse_a11y_score.sql is_root_page * Update page_title.sql is_root_page * Update pages_with_search_input.sql is_root_page * Update placeholder_but_no_label.sql is_root_page * Update sites_using_role.sql is_root_page * Update skip_links.sql is_root_page * Update sr_only_classes.sql is_root_page * Update tabindex_usage_and_values.sql is_root_page * Update table_stats.sql is_root_page * Update valid_html_lang.sql is_root_page * Update video_track_usage.sql is_root_page * Update viewport_zoom_scale.sql is_root_page * Update viewport_zoom_scale_by_domain_rank.sql is_root_page * Update viewport_zoom_scale.sql removing spaces * Update valid_html_lang.sql removing spaces * Update placeholder_but_no_label.sql Spaces * Update lighthouse_a11y_score.sql spaces * Update a11y_technology_usage.sql spaces * Create a11y_frontend_technology.sql * Create focus_outline_0.sql This seems to work. * Update a11y_frontend_technology.sql white spaces * Update a11y_frontend_technology.sql Linting * Create focus_visible.sql Adding focus visible check * Update focus_visible.sql Updating the year. * Update focus_visible.sql this seems to work better. * Update focus_visible.sql Fixing linting * Create media_query_features.sql Seems to be working. * Create units_properties.sql Seems to be working * Create lighthouse_per_cms.sql * Rename lighthouse_per_cms.sql to lighthouse_score_by_cms.sql title change * Update lighthouse_score_by_cms.sql Adding back in best practices. * Update lighthouse_score_by_cms.sql * Update lighthouse_score_by_cms.sql removing rounding and commented out code * Update lighthouse_score_by_cms.sql removing round and fixing best-practices * Create lighthouse_score_by_government.sql Adding country specific scans. * Rename lighthouse_score_by_country.sql to lighthouse_score_by_government.sql for consistency * Update lighthouse_score_by_government.sql Adding more governments. * Update lighthouse_score_by_government.sql Adding US States * Create lighthouse_by_frontend_framework.sql * Rename lighthouse_by_frontend_framework.sql to lighthouse_score_by_frontend.sql title update * Update lighthouse_score_by_government.sql white space * Update lighthouse_score_by_frontend.sql white space & linting * Update lighthouse_score_by_cms.sql white space * Update focus_outline_0.sql expanding the returned results * Update lighthouse_score_by_frontend.sql linting * Update lighthouse_score_by_government.sql Linting * Update lighthouse_score_by_government.sql Linting * Update landmark_elements_and_roles.sql Updated query * Update landmark_elements_and_roles.sql linting - white space * Update lighthouse_score_by_government.sql Trying to standardize count to address linting issue. * Update common_aria_role.sql Update to make sure we're getting percentages. * Update common_element_attributes.sql updating for percentages * Update a11y_technology_usage_by_domain_rank.sql Query that is producing better results. * Update a11y_technology_usage_by_domain_rank.sql Linting * Update landmark_elements_and_roles.sql Fixed query - Thanks to @tunetheweb * Update a11y_technology_usage_by_domain_rank.sql spaces * Create lighthouse_score_by_country.sql Adding country references * Create lighthouse_score_by_tld.sql Adding query by TLD * Update lighthouse_score_by_government.sql Making query case insensitive * Update lighthouse_score_by_government.sql Adding Mass.gov * Update lighthouse_a11y_score.sql The value was still rounded so lost valuable info * Update lighthouse_a11y_score.sql Avoiding approximate values for the return. * Update lighthouse_score_by_tld.sql Linting * Update lighthouse_a11y_score.sql Linting * Create lighthouse_a11y_audits_by_cms.sql Query to highlight the types of errors produced by popular CMS. * Update lighthouse_a11y_score.sql Linting * Update a11y_technology_usage_by_domain_rank.sql Linting * Update sql/2024/accessibility/lighthouse_score_by_government.sql Double quotes... Co-authored-by: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com> * Update viewport_zoom_scale_by_domain_rank.sql Updating SQL to get rank right. * Update lighthouse_score_by_government.sql Some simple name changes. * Update lighthouse_score_by_government.sql Including secondary pages. * Create lighthouse_a11y_by_government_with_urls.sql Adding new SQL to check results of query * Update and rename lighthouse_a11y_by_government_with_urls.sql to lighthouse_a11y_score_by_government_with_urls.sql Finding the missing countries... * Rename lighthouse_a11y_score_by_government_with_urls.sql to lighthouse_score_by_government_with_urls.sql renaming * Update lighthouse_score_by_government.sql UPdating query * Update lighthouse_score_by_government.sql Reducing errors like https://www.stats.gov.nl.ca/ landing in the Netherlands rather than Canada. * Update lighthouse_score_by_government.sql Correcting Belgium's domains * Update lighthouse_score_by_government.sql Updating finland. * Update lighthouse_score_by_government.sql Adding lithuania * Update lighthouse_score_by_government.sql Updating the netherlands * Update lighthouse_score_by_government.sql Adding Swedish domains. * Update lighthouse_score_by_government.sql Updating where statement. * Update lighthouse_score_by_government.sql Adding more UN organizations. * Update lighthouse_score_by_government.sql Optimized WHERE clause. * Update lighthouse_score_by_government.sql Updating where * Update lighthouse_score_by_government.sql Update to where. * Update lighthouse_score_by_government.sql More flexible query. * Update lighthouse_score_by_government.sql Spacing for linting * Update lighthouse_score_by_government_with_urls.sql Standardizing government queries. * Update viewport_zoom_scale_by_domain_rank.sql Linting problem * Update lighthouse_score_by_government_with_urls.sql Checking linter.. * Update lighthouse_score_by_government.sql Correcting parse error * Update viewport_zoom_scale_by_domain_rank.sql linting * Update viewport_zoom_scale_by_domain_rank.sql Linting * Update lighthouse_score_by_government.sql More consistency * Update lighthouse_score_by_government_with_urls.sql Consistency in domains... * Update lighthouse_score_by_government_with_urls.sql adding more countries * Update lighthouse_score_by_government.sql Adding other countries * Update lighthouse_score_by_government_with_urls.sql Trying to further maximize the number of government domains returned and sorted. * Update lighthouse_score_by_government_with_urls.sql Linting * Update lighthouse_score_by_government.sql Updating URL to keep up with maximizing URLs. * Update lighthouse_score_by_government_with_urls.sql Updating list of government sites. * Update lighthouse_score_by_government.sql Updating lists of government sites. * Update lighthouse_score_by_government_with_urls.sql More Finish governments * Update lighthouse_score_by_government_with_urls.sql More finland domains. * Update lighthouse_score_by_government_with_urls.sql adding more European country exceptions. * Update lighthouse_score_by_government_with_urls.sql Updating country listings. * Update lighthouse_score_by_government_with_urls.sql Updates for Canadian provinces * Update lighthouse_score_by_government_with_urls.sql Improvements in the categorization. * Update lighthouse_score_by_government_with_urls.sql Adding Luxemburg domain * Update lighthouse_score_by_government_with_urls.sql Adding Andorra * Update lighthouse_score_by_government_with_urls.sql Linting issues * Update lighthouse_score_by_government.sql Updating domains for consistency * Update lighthouse_score_by_government.sql Including unique identifier for the URL/test * Update lighthouse_score_by_government.sql Not useful in an average * Update lighthouse_score_by_government_with_urls.sql Adding wptid Including correlations for all of the world's countries. * Update lighthouse_score_by_government_with_urls.sql Making the query more consistent * Update lighthouse_score_by_government_with_urls.sql removing duplicates * Update lighthouse_score_by_government_with_urls.sql Cleaner URLs * Update lighthouse_score_by_government_with_urls.sql Updated countries.... * Update lighthouse_score_by_government_with_urls.sql Finally with the "Other" not showing up for all of the domains.... REGEX problems... * Update lighthouse_score_by_government.sql Updates to improve country coverage * Update lighthouse_score_by_government.sql Adding Norway and Greenland * Update lighthouse_score_by_government_with_urls.sql Adding Norway and Greenland * Update lighthouse_score_by_government_with_urls.sql Adding Iran and note about https://state.mn.us/ coverage too. * Update lighthouse_score_by_government_with_urls.sql Linting issues * Update lighthouse_score_by_government.sql Linting * Update lighthouse_score_by_government.sql Linting * Update lighthouse_score_by_government_with_urls.sql Linting * Update lighthouse_score_by_government_with_urls.sql Linting... * Update lighthouse_score_by_government_with_urls.sql spacing (hopefully the last) * Update lighthouse_score_by_government.sql Final space hopefully * Update button_name_sources.sql Removing is_root_page so that it is easier to calculate the a comparable value. * Update alt_ending_in_image_extension.sql Thanks to @tunetheweb for this. * Update common_alt_text_length.sql --------- Co-authored-by: Barry Pollard <barrypollard@google.com> Co-authored-by: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
1 parent 89f8801 commit 5bdb523

41 files changed

Lines changed: 3269 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
WITH score_data AS (
2+
SELECT
3+
client,
4+
page,
5+
CAST(JSON_EXTRACT_SCALAR(lighthouse, '$.categories.performance.score') AS FLOAT64) AS performance_score,
6+
CAST(JSON_EXTRACT_SCALAR(lighthouse, '$.categories.accessibility.score') AS FLOAT64) AS accessibility_score,
7+
CAST(JSON_EXTRACT_SCALAR(lighthouse, '$.categories.best-practices.score') AS FLOAT64) AS best_practices_score,
8+
CAST(JSON_EXTRACT_SCALAR(lighthouse, '$.categories.seo.score') AS FLOAT64) AS seo_score,
9+
t.technology AS framework
10+
FROM
11+
`httparchive.all.pages`,
12+
UNNEST(technologies) AS t
13+
WHERE
14+
date = '2024-06-01' AND
15+
lighthouse IS NOT NULL AND
16+
lighthouse != '{}' AND
17+
is_root_page = TRUE AND
18+
('Web frameworks' IN UNNEST(t.categories) OR 'JavaScript libraries' IN UNNEST(t.categories) OR 'Frontend frameworks' IN UNNEST(t.categories) OR 'JavaScript frameworks' IN UNNEST(t.categories)) AND
19+
t.technology IS NOT NULL
20+
)
21+
22+
SELECT
23+
client,
24+
framework,
25+
AVG(performance_score) AS avg_performance_score,
26+
AVG(accessibility_score) AS avg_accessibility_score,
27+
AVG(best_practices_score) AS avg_best_practices_score,
28+
AVG(seo_score) AS avg_seo_score,
29+
COUNT(DISTINCT page) AS total_pages
30+
FROM (
31+
SELECT
32+
client,
33+
page,
34+
framework,
35+
AVG(performance_score) AS performance_score, # All scores are the same for one page (we have multiple rows due to unnest), we could also take the first instead of the average
36+
AVG(accessibility_score) AS accessibility_score,
37+
AVG(best_practices_score) AS best_practices_score,
38+
AVG(seo_score) AS seo_score
39+
FROM
40+
score_data
41+
GROUP BY
42+
client,
43+
page,
44+
framework
45+
)
46+
GROUP BY
47+
client,
48+
framework
49+
ORDER BY
50+
total_pages DESC;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#standardSQL
2+
# Overall Accessibility (A11y) technology, ie. Overlays, usage by domain rank
3+
4+
# Main SELECT statement to aggregate results by client and rank grouping.
5+
SELECT
6+
client,
7+
is_root_page,
8+
rank_grouping, # Grouping of domains by their rank (e.g., top 1000, top 10000, etc.)
9+
total_in_rank, # Total number of sites within the rank grouping
10+
COUNT(DISTINCT page) AS sites_with_a11y_tech, # Number of unique sites that use accessibility technology
11+
COUNT(DISTINCT page) / total_in_rank AS pct_sites_with_a11y_tech # Percentage of sites using accessibility technology within the rank grouping
12+
FROM
13+
(
14+
# Subquery to filter and extract relevant pages with A11Y technology
15+
SELECT DISTINCT
16+
client,
17+
is_root_page,
18+
page,
19+
rank_grouping,
20+
category
21+
FROM
22+
`httparchive.all.pages`,
23+
UNNEST([1000, 10000, 100000, 1000000, 10000000, 100000000]) AS rank_grouping, # Expand rank_grouping to cover different rank categories
24+
UNNEST(technologies) AS tech,
25+
UNNEST(categories) AS category
26+
WHERE
27+
date = '2024-06-01' AND
28+
category = 'Accessibility' AND
29+
rank <= rank_grouping # Include only sites within the specified rank grouping
30+
)
31+
JOIN
32+
(
33+
# Subquery to count total sites in each rank grouping for each client
34+
SELECT
35+
client,
36+
rank_grouping,
37+
COUNT(0) AS total_in_rank
38+
FROM
39+
`httparchive.all.pages`,
40+
UNNEST([1000, 10000, 100000, 1000000, 10000000, 100000000]) AS rank_grouping
41+
WHERE
42+
date = '2024-06-01' AND
43+
rank <= rank_grouping
44+
GROUP BY
45+
client,
46+
rank_grouping
47+
) USING (client, rank_grouping)
48+
GROUP BY
49+
client,
50+
is_root_page,
51+
rank_grouping,
52+
total_in_rank
53+
ORDER BY
54+
client,
55+
is_root_page,
56+
rank_grouping
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#standardSQL
2+
# Accessibility (A11y) technology, ie. Overlays, usage by client
3+
4+
SELECT
5+
client, # Client domain
6+
is_root_page,
7+
COUNT(DISTINCT page) AS total_sites, # Total number of unique sites for the client
8+
COUNT(DISTINCT IF(category = 'Accessibility', page, NULL)) AS sites_with_a11y_tech, # Number of unique sites that use accessibility technology
9+
COUNT(DISTINCT IF(category = 'Accessibility', page, NULL)) / COUNT(DISTINCT page) AS pct_sites_with_a11y_tech # Percentage of sites using accessibility technology
10+
FROM
11+
`httparchive.all.pages`,
12+
UNNEST(technologies) AS tech,
13+
UNNEST(categories) AS category
14+
WHERE
15+
date = '2024-06-01' # Specific date for data extraction
16+
GROUP BY
17+
client,
18+
is_root_page
19+
ORDER BY
20+
client,
21+
is_root_page;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#standardSQL
2+
# A11Y technology usage by domain rank
3+
WITH ranked_sites AS (
4+
-- Get the total number of sites within each rank grouping
5+
SELECT
6+
client,
7+
is_root_page,
8+
page,
9+
rank,
10+
technologies, -- Include technologies field here
11+
CASE
12+
WHEN rank <= 1000 THEN 1000
13+
WHEN rank <= 10000 THEN 10000
14+
WHEN rank <= 100000 THEN 100000
15+
WHEN rank <= 1000000 THEN 1000000
16+
WHEN rank <= 10000000 THEN 10000000
17+
WHEN rank <= 100000000 THEN 100000000
18+
END AS rank_grouping
19+
FROM
20+
`httparchive.all.pages`
21+
WHERE
22+
date = '2024-06-01' -- Use the relevant date for analysis
23+
),
24+
25+
rank_totals AS (
26+
-- Calculate total sites in each rank grouping
27+
SELECT
28+
client,
29+
is_root_page,
30+
rank_grouping,
31+
COUNT(DISTINCT page) AS total_in_rank
32+
FROM
33+
ranked_sites
34+
GROUP BY
35+
client,
36+
is_root_page,
37+
rank_grouping
38+
)
39+
40+
SELECT
41+
r.client,
42+
r.is_root_page,
43+
r.rank_grouping,
44+
rt.total_in_rank, -- Total number of unique sites within the rank grouping
45+
tech.technology AS app, -- Accessibility technology used
46+
COUNT(DISTINCT r.page) AS sites_with_app, -- Number of sites using the specific accessibility technology
47+
SAFE_DIVIDE(COUNT(DISTINCT r.page), rt.total_in_rank) AS pct_sites_with_app -- Percentage of sites using the accessibility technology
48+
FROM
49+
ranked_sites r
50+
JOIN
51+
UNNEST(r.technologies) AS tech -- Expand technologies array to individual rows
52+
JOIN
53+
rank_totals rt -- Join to get the total number of sites per rank grouping
54+
ON r.client = rt.client AND
55+
r.is_root_page = rt.is_root_page AND
56+
r.rank_grouping = rt.rank_grouping
57+
JOIN
58+
UNNEST(tech.categories) AS category -- Unnest the categories array to filter for accessibility
59+
WHERE
60+
category = 'Accessibility' -- Filter to include only accessibility-related technologies
61+
GROUP BY
62+
r.client,
63+
r.is_root_page,
64+
r.rank_grouping,
65+
rt.total_in_rank,
66+
tech.technology
67+
ORDER BY
68+
tech.technology, -- Order results by technology (app)
69+
r.rank_grouping, -- Order results by rank grouping
70+
r.client,
71+
r.is_root_page;
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#standardSQL
2+
# Alt text ending in an image extension
3+
CREATE TEMPORARY FUNCTION getUsedExtensions(payload STRING)
4+
RETURNS ARRAY<STRUCT<extension STRING, total INT64>> LANGUAGE js AS '''
5+
try {
6+
const a11y = JSON.parse(payload);
7+
8+
return Object.entries(a11y.file_extension_alts.file_extensions).map(([extension, total]) => {
9+
return {extension, total};
10+
});
11+
} catch (e) {
12+
return [];
13+
}
14+
''';
15+
SELECT
16+
client,
17+
is_root_page,
18+
sites_with_non_empty_alt,
19+
sites_with_file_extension_alt,
20+
total_alts_with_file_extensions,
21+
22+
# Of sites with a non-empty alt, what % have an alt with a file extension
23+
sites_with_file_extension_alt / sites_with_non_empty_alt AS pct_sites_with_file_extension_alt,
24+
# Given a random alt, how often will it end in a file extension
25+
total_alts_with_file_extensions / total_non_empty_alts AS pct_alts_with_file_extension,
26+
27+
extension_stat.extension AS extension,
28+
COUNT(0) AS total_sites_using,
29+
# Of sites with a non-empty alt, what % have an alt with this file extension
30+
COUNT(0) / sites_with_non_empty_alt AS pct_applicable_sites_using,
31+
32+
# Of sites with a non-empty alt, what % have an alt with this file extension
33+
SUM(extension_stat.total) AS total_occurances,
34+
# Given a random alt ending in a file extension, how often will it end in this file extension
35+
SUM(extension_stat.total) / total_alts_with_file_extensions AS pct_total_occurances
36+
FROM
37+
`httparchive.all.pages`,
38+
UNNEST(getUsedExtensions(JSON_EXTRACT(custom_metrics, '$.a11y'))) AS extension_stat
39+
LEFT JOIN (
40+
SELECT
41+
client,
42+
is_root_page,
43+
COUNTIF(total_non_empty_alt > 0) AS sites_with_non_empty_alt,
44+
COUNTIF(total_with_file_extension > 0) AS sites_with_file_extension_alt,
45+
46+
SUM(total_non_empty_alt) AS total_non_empty_alts,
47+
SUM(total_with_file_extension) AS total_alts_with_file_extensions
48+
FROM (
49+
SELECT
50+
client,
51+
is_root_page,
52+
CAST(JSON_EXTRACT_SCALAR(custom_metrics, '$.markup.images.img.alt.present') AS INT64) AS total_non_empty_alt,
53+
CAST(JSON_EXTRACT_SCALAR(custom_metrics, '$.a11y.file_extension_alts.total_with_file_extension') AS INT64) AS total_with_file_extension
54+
FROM
55+
`httparchive.all.pages`
56+
WHERE
57+
date = '2024-06-01'
58+
)
59+
GROUP BY
60+
client,
61+
is_root_page
62+
) USING (client, is_root_page)
63+
WHERE
64+
date = '2024-06-01'
65+
GROUP BY
66+
client,
67+
is_root_page,
68+
sites_with_non_empty_alt,
69+
sites_with_file_extension_alt,
70+
total_non_empty_alts,
71+
total_alts_with_file_extensions,
72+
extension
73+
ORDER BY
74+
client,
75+
is_root_page,
76+
total_occurances DESC
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#standardSQL
2+
# Anchors with role='button'
3+
SELECT
4+
client,
5+
is_root_page,
6+
COUNTIF(total_anchors > 0) AS sites_with_anchors,
7+
COUNTIF(total_anchors_with_role_button > 0) AS sites_with_anchor_role_button,
8+
9+
# Of sites that have anchors... how many have an anchor with a role='button'
10+
COUNTIF(total_anchors_with_role_button > 0) / COUNTIF(total_anchors > 0) AS pct_sites_with_anchor_role_button
11+
FROM (
12+
SELECT
13+
client,
14+
is_root_page,
15+
date,
16+
CAST(JSON_EXTRACT_SCALAR(JSON_EXTRACT_SCALAR(payload, '$._a11y'), '$.total_anchors_with_role_button') AS INT64) AS total_anchors_with_role_button,
17+
IFNULL(CAST(JSON_EXTRACT_SCALAR(JSON_EXTRACT_SCALAR(payload, '$._element_count'), '$.a') AS INT64), 0) AS total_anchors
18+
FROM
19+
`httparchive.all.pages`
20+
)
21+
WHERE
22+
date = '2024-06-01'
23+
GROUP BY
24+
client,
25+
is_root_page;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#standardSQL
2+
# Audio elements track usage
3+
SELECT
4+
client,
5+
is_root_page,
6+
COUNT(0) AS total_sites,
7+
COUNTIF(total_audios > 0) AS total_with_audio,
8+
COUNTIF(total_with_track > 0) AS total_with_tracks,
9+
10+
SUM(total_with_track) / SUM(total_audios) AS pct_audios_with_tracks,
11+
COUNTIF(total_audios > 0) / COUNT(0) AS pct_sites_with_audios,
12+
COUNTIF(total_with_track > 0) / COUNTIF(total_audios > 0) AS pct_audio_sites_with_tracks
13+
FROM (
14+
SELECT
15+
client,
16+
is_root_page,
17+
date,
18+
CAST(JSON_EXTRACT_SCALAR(JSON_EXTRACT_SCALAR(payload, '$._almanac'), '$.audios.total') AS INT64) AS total_audios,
19+
CAST(JSON_EXTRACT_SCALAR(JSON_EXTRACT_SCALAR(payload, '$._almanac'), '$.audios.total_with_track') AS INT64) AS total_with_track
20+
FROM
21+
`httparchive.all.pages`
22+
WHERE
23+
date = '2024-06-01'
24+
)
25+
GROUP BY
26+
client,
27+
is_root_page;

0 commit comments

Comments
 (0)