Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions jobs/webcompat-kb/data/metrics/metrics.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pretty_name = "Sightline"
type = "site_reports_field"
host_min_ranks_condition = "MIN(japan_rank) <= 1000"
pretty_name = "Japan"
tlds = [".jp"]
dashboards = ["country_webcompat_overview"]

[japan_1000_mobile]
type = "site_reports_field"
Expand All @@ -36,6 +38,7 @@ pretty_name = "Global 5000"
type = "site_reports_field"
host_min_ranks_condition = "MIN(us_rank) <= 1000"
pretty_name = "USA"
dashboards = ["country_webcompat_overview"]

[us_1000_mobile]
type = "site_reports_field"
Expand All @@ -46,6 +49,8 @@ pretty_name = "USA Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(germany_rank) <= 1000"
pretty_name = "Germany"
tlds = [".de"]
dashboards = ["country_webcompat_overview"]

[germany_1000_mobile]
type = "site_reports_field"
Expand All @@ -56,6 +61,8 @@ pretty_name = "Germany Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(france_rank) <= 1000"
pretty_name = "France"
tlds = [".fr"]
dashboards = ["country_webcompat_overview"]

[france_1000_mobile]
type = "site_reports_field"
Expand All @@ -66,6 +73,8 @@ pretty_name = "France Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(uk_rank) <= 1000"
pretty_name = "UK"
tlds = [".uk", ".co.uk"]
dashboards = ["country_webcompat_overview"]

[uk_1000_mobile]
type = "site_reports_field"
Expand All @@ -76,6 +85,8 @@ pretty_name = "UK Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(canada_rank) <= 1000"
pretty_name = "Canada"
tlds = [".ca"]
dashboards = ["country_webcompat_overview"]

[canada_1000_mobile]
type = "site_reports_field"
Expand All @@ -86,6 +97,8 @@ pretty_name = "Canada Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(poland_rank) <= 1000"
pretty_name = "Poland"
tlds = [".pl"]
dashboards = ["country_webcompat_overview"]

[poland_1000_mobile]
type = "site_reports_field"
Expand All @@ -96,6 +109,8 @@ pretty_name = "Poland Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(india_rank) <= 1000"
pretty_name = "India"
tlds = [".in"]
dashboards = ["country_webcompat_overview"]

[india_1000_mobile]
type = "site_reports_field"
Expand All @@ -106,6 +121,8 @@ pretty_name = "India Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(brazil_rank) <= 1000"
pretty_name = "Brazil"
tlds = [".br"]
dashboards = ["country_webcompat_overview"]

[brazil_1000_mobile]
type = "site_reports_field"
Expand All @@ -116,6 +133,8 @@ pretty_name = "Brazil Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(indonesia_rank) <= 1000"
pretty_name = "Indonesia"
tlds = [".id"]
dashboards = ["country_webcompat_overview"]

[indonesia_1000_mobile]
type = "site_reports_field"
Expand All @@ -126,6 +145,8 @@ pretty_name = "Indonesia Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(mexico_rank) <= 1000"
pretty_name = "Mexico"
tlds = [".mx"]
dashboards = ["country_webcompat_overview"]

[mexico_1000_mobile]
type = "site_reports_field"
Expand All @@ -136,6 +157,8 @@ pretty_name = "Mexico Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(italy_rank) <= 1000"
pretty_name = "Italy"
tlds = [".it"]
dashboards = ["country_webcompat_overview"]

[italy_1000_mobile]
type = "site_reports_field"
Expand All @@ -146,6 +169,8 @@ pretty_name = "Italy Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(spain_rank) <= 1000"
pretty_name = "Spain"
tlds = [".es"]
dashboards = ["country_webcompat_overview"]

[spain_1000_mobile]
type = "site_reports_field"
Expand All @@ -156,6 +181,8 @@ pretty_name = "Spain Mobile"
type = "site_reports_field"
host_min_ranks_condition = "MIN(netherlands_rank) <= 1000"
pretty_name = "Netherlands"
tlds = [".nl"]
dashboards = ["country_webcompat_overview"]

[netherlands_1000_mobile]
type = "site_reports_field"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "Country Specific Top Bugs"
id = 109086
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[platforms]
title = "Platforms"
type = "enum"
value = "All"
enum_options = ["All", "Mobile", "Desktop"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SELECT
number,
title,
cast(score as int) as `Impact Score`,
webcompat_priority, net.host(url) as host,
ARRAY_TO_STRING(next_action_teams, ",") as team
FROM `{{ ref("webcompat_knowledge_base.scored_site_reports") }}` AS bugs
JOIN `{{ ref("webcompat_knowledge_base.site_reports_next_action") }}` USING(number)
WHERE bugs.resolution = "" AND (
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
) AND CASE "{{ param("platforms") }}"
WHEN "All" THEN TRUE
WHEN "Mobile" THEN is_mobile
WHEN "Desktop" THEN is_desktop
END
ORDER BY score DESC
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "Country Top 1000 Bugs"
id = 109062
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[platforms]
title = "Platforms"
type = "enum"
value = "All"
enum_options = ["All", "Mobile", "Desktop"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
SELECT
number,
title,
cast(score as int) as `Impact Score`,
webcompat_priority, net.host(url) as host,
ARRAY_TO_STRING(next_action_teams, ",") as team
FROM `{{ ref("webcompat_knowledge_base.scored_site_reports") }}` AS bugs
JOIN `{{ ref("webcompat_knowledge_base.site_reports_next_action") }}` USING(number)
WHERE bugs.resolution = "" AND
CASE "{{ param("country") }}"
{% for metric in dashboard_metrics %}
WHEN "{{ metric.pretty_name }}" THEN {{ metric.condition("bugs") }}
{% endfor %}
ELSE FALSE
END
AND CASE "{{ param("platforms") }}"
WHEN "All" THEN TRUE
WHEN "Mobile" THEN is_mobile
WHEN "Desktop" THEN is_desktop
END
ORDER BY score DESC
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "country_webcompat_overview"
description = "Country WebCompat Overview"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[country]
title = "Country"
type = "enum"
enum_options = [{% for metric in dashboard_metrics %}"{{ metric.pretty_name }}",
{% endfor %}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name = "Country Topline Metric"
id = 109084
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT date,
{% for field in ["bug_count", "not_supported_score", "total_score", "needs_diagnosis_score"] %}
CASE "{{ param("country") }}"
{% for metric in dashboard_metrics %}
WHEN "{{ metric.pretty_name }}" THEN cast({{ field }}_{{ metric.name }} as int)
{% endfor %}
END as {{ field }},
CASE "{{ param("country") }}"
{% for metric in dashboard_metrics %}
WHEN "{{ metric.pretty_name }}" THEN cast({{ field }}_{{ metric.name }}_mobile as int)
{% endfor %}
END as {{ field }}_mobile{{ "," if not loop.last }}
{% endfor %}
FROM `{{ ref("webcompat_knowledge_base.webcompat_topline_metric_daily") }}`
ORDER BY date DESC;
10 changes: 10 additions & 0 deletions jobs/webcompat-kb/docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ defined:
joined with `AND`. When this is not supplied the default condition
is `host_categories.is_{metric_name}`.

The following optional fields are used by the country WebCompat dashboard
(`country_webcompat_overview`):

* `tlds` - Optional list of country top-level domain strings
(e.g. `[".jp"]`, `[".uk", ".co.uk"]`). When set, the
`country_specific_top_bugs` query adds `OR net.host(url) LIKE "%{tld}"`
clauses so that bugs are surfaced by domain suffix regardless of ranking.
Omit for countries where the TLD is not country-specific (e.g. USA, where
`.com` is global).

## Site Rank Definitions

Metrics often depend on the popularity of a site. This data is stored
Expand Down
4 changes: 4 additions & 0 deletions jobs/webcompat-kb/webcompat_kb/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ def __init__(
site_reports_conditions: Optional[list[str]],
pretty_name: Optional[str] = None,
dashboards: Optional[list[str]] = None,
tlds: Optional[list[str]] = None,
):
super().__init__(name, pretty_name, dashboards)
self._host_min_ranks_condition = host_min_ranks_condition
self._site_reports_conditions = site_reports_conditions
self.tlds = tlds or []

def condition(self, table: str) -> str:
return f"{table}.is_{self.name}"
Expand Down Expand Up @@ -86,6 +88,7 @@ class SiteReportsFieldMetricData(BaseModel):
conditions: Optional[list[str]] = None
pretty_name: Optional[str] = None
dashboards: Optional[list[str]] = None
tlds: Optional[list[str]] = None

def to_metric(self, name: str) -> SiteReportsFieldMetric:
return SiteReportsFieldMetric(
Expand All @@ -94,6 +97,7 @@ def to_metric(self, name: str) -> SiteReportsFieldMetric:
self.conditions,
self.pretty_name,
self.dashboards,
self.tlds,
)


Expand Down