From aeaa6c614ea4138b3f36e2d656f79c9da9060e5a Mon Sep 17 00:00:00 2001 From: Martin Balfanz Date: Fri, 24 Apr 2026 12:17:14 +0200 Subject: [PATCH 1/2] Add country bug counts to 'country webcompat dashboard' --- .../country_counts/meta.toml | 2 + .../country_counts/query.sql | 87 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/meta.toml create mode 100644 jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/query.sql diff --git a/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/meta.toml b/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/meta.toml new file mode 100644 index 00000000..117a917b --- /dev/null +++ b/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/meta.toml @@ -0,0 +1,2 @@ +name = "Country Specific Counts" +id = 116832 diff --git a/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/query.sql b/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/query.sql new file mode 100644 index 00000000..7df52e50 --- /dev/null +++ b/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/query.sql @@ -0,0 +1,87 @@ +WITH bugs_with_flags AS ( + SELECT + score, + metric_type_firefox_not_supported, + webcompat_priority, + is_mobile, + is_desktop, + CASE "{{ param("country") }}" + {% for metric in dashboard_metrics %} + WHEN "{{ metric.pretty_name }}" THEN {{ metric.condition("bugs") }} + {% endfor %} + ELSE FALSE + END AS is_country_all, + CASE "{{ param("country") }}" + {% for metric in dashboard_metrics %} + WHEN "{{ metric.pretty_name }}" THEN ( + ({{ metric.condition("bugs") }} AND NOT bugs.is_global_1000) + {% for tld in metric.tlds %} + OR net.host(url) LIKE "%{{ tld }}" + {% endfor %} + ) + {% endfor %} + ELSE FALSE + END AS is_country_specific + FROM `{{ ref("webcompat_knowledge_base.scored_site_reports") }}` AS bugs + WHERE bugs.resolution = "" +) + +SELECT "All" AS webcompat_priority, + COUNTIF(is_country_all) AS bug_count_all, + COUNTIF(is_country_all AND is_mobile) AS bug_count_all_mobile, + COUNTIF(is_country_all AND is_desktop) AS bug_count_all_desktop, + COUNTIF(is_country_specific) AS bug_count_specific, + COUNTIF(is_country_specific AND is_mobile) AS bug_count_specific_mobile, + COUNTIF(is_country_specific AND is_desktop) AS bug_count_specific_desktop, + cast(SUM(IF(is_country_all, score, 0)) as int) AS score_all, + cast(SUM(IF(is_country_all AND is_mobile, score, 0)) as int) AS score_all_mobile, + cast(SUM(IF(is_country_all AND is_desktop, score, 0)) as int) AS score_all_desktop, + cast(SUM(IF(is_country_specific, score, 0)) as int) AS score_specific, + cast(SUM(IF(is_country_specific AND is_mobile, score, 0)) as int) AS score_specific_mobile, + cast(SUM(IF(is_country_specific AND is_desktop, score, 0)) as int) AS score_specific_desktop, + 100 * SAFE_DIVIDE(COUNTIF(is_country_specific), COUNTIF(is_country_all)) AS share_bugs, + 100 * SAFE_DIVIDE(COUNTIF(is_country_specific AND is_mobile), COUNTIF(is_country_all AND is_mobile)) AS share_bugs_mobile, + 100 * SAFE_DIVIDE(COUNTIF(is_country_specific AND is_desktop), COUNTIF(is_country_all AND is_desktop)) AS share_bugs_desktop, + 100 * SAFE_DIVIDE(SUM(IF(is_country_specific, score, 0)), SUM(IF(is_country_all, score, 0))) AS share_score, + 100 * SAFE_DIVIDE(SUM(IF(is_country_specific AND is_mobile, score, 0)), SUM(IF(is_country_all AND is_mobile, score, 0))) AS share_score_mobile, + 100 * SAFE_DIVIDE(SUM(IF(is_country_specific AND is_desktop, score, 0)), SUM(IF(is_country_all AND is_desktop, score, 0))) AS share_score_desktop, + COUNTIF(is_country_specific AND metric_type_firefox_not_supported) AS not_supported_count_specific, + COUNTIF(is_country_specific AND is_mobile AND metric_type_firefox_not_supported) AS not_supported_count_specific_mobile, + COUNTIF(is_country_specific AND is_desktop AND metric_type_firefox_not_supported) AS not_supported_count_specific_desktop +FROM bugs_with_flags + +UNION ALL + +SELECT + webcompat_priority, + COUNTIF(is_country_all) AS bug_count_all, + COUNTIF(is_country_all AND is_mobile) AS bug_count_all_mobile, + COUNTIF(is_country_all AND is_desktop) AS bug_count_all_desktop, + COUNTIF(is_country_specific) AS bug_count_specific, + COUNTIF(is_country_specific AND is_mobile) AS bug_count_specific_mobile, + COUNTIF(is_country_specific AND is_desktop) AS bug_count_specific_desktop, + cast(SUM(IF(is_country_all, score, 0)) as int) AS score_all, + cast(SUM(IF(is_country_all AND is_mobile, score, 0)) as int) AS score_all_mobile, + cast(SUM(IF(is_country_all AND is_desktop, score, 0)) as int) AS score_all_desktop, + cast(SUM(IF(is_country_specific, score, 0)) as int) AS score_specific, + cast(SUM(IF(is_country_specific AND is_mobile, score, 0)) as int) AS score_specific_mobile, + cast(SUM(IF(is_country_specific AND is_desktop, score, 0)) as int) AS score_specific_desktop, + 100 * SAFE_DIVIDE(COUNTIF(is_country_specific), COUNTIF(is_country_all)) AS share_bugs, + 100 * SAFE_DIVIDE(COUNTIF(is_country_specific AND is_mobile), COUNTIF(is_country_all AND is_mobile)) AS share_bugs_mobile, + 100 * SAFE_DIVIDE(COUNTIF(is_country_specific AND is_desktop), COUNTIF(is_country_all AND is_desktop)) AS share_bugs_desktop, + 100 * SAFE_DIVIDE(SUM(IF(is_country_specific, score, 0)), SUM(IF(is_country_all, score, 0))) AS share_score, + 100 * SAFE_DIVIDE(SUM(IF(is_country_specific AND is_mobile, score, 0)), SUM(IF(is_country_all AND is_mobile, score, 0))) AS share_score_mobile, + 100 * SAFE_DIVIDE(SUM(IF(is_country_specific AND is_desktop, score, 0)), SUM(IF(is_country_all AND is_desktop, score, 0))) AS share_score_desktop, + COUNTIF(is_country_specific AND metric_type_firefox_not_supported) AS not_supported_count_specific, + COUNTIF(is_country_specific AND is_mobile AND metric_type_firefox_not_supported) AS not_supported_count_specific_mobile, + COUNTIF(is_country_specific AND is_desktop AND metric_type_firefox_not_supported) AS not_supported_count_specific_desktop +FROM bugs_with_flags +GROUP BY webcompat_priority +HAVING webcompat_priority IN ("P1", "P2", "P3") + +ORDER BY CASE webcompat_priority + WHEN "All" THEN 0 + WHEN "P1" THEN 1 + WHEN "P2" THEN 2 + WHEN "P3" THEN 3 +END From c4d0a387a69361bd117bea59b7fef72548b53203 Mon Sep 17 00:00:00 2001 From: Martin Balfanz Date: Fri, 24 Apr 2026 14:34:31 +0200 Subject: [PATCH 2/2] Include tlds in country_all list --- .../country_webcompat_overview/country_counts/query.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/query.sql b/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/query.sql index 7df52e50..da61322e 100644 --- a/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/query.sql +++ b/jobs/webcompat-kb/data/redash/country_webcompat_overview/country_counts/query.sql @@ -7,7 +7,12 @@ WITH bugs_with_flags AS ( is_desktop, CASE "{{ param("country") }}" {% for metric in dashboard_metrics %} - WHEN "{{ metric.pretty_name }}" THEN {{ metric.condition("bugs") }} + WHEN "{{ metric.pretty_name }}" THEN ( + {{ metric.condition("bugs") }} + {% for tld in metric.tlds %} + OR net.host(url) LIKE "%{{ tld }}" + {% endfor %} + ) {% endfor %} ELSE FALSE END AS is_country_all,