diff --git a/jobs/webcompat-kb/data/metrics/rescores.toml b/jobs/webcompat-kb/data/metrics/rescores.toml index e69de29b..21311c10 100644 --- a/jobs/webcompat-kb/data/metrics/rescores.toml +++ b/jobs/webcompat-kb/data/metrics/rescores.toml @@ -0,0 +1,6 @@ +[crux_202512] +reason = "Update CrUX data to 202512" +routine_updates = [ + "moz-fx-dev-dschubert-wckb.webcompat_knowledge_base.WEBCOMPAT_METRIC_YYYYMM", +] +stage = true diff --git a/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/routines/RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM/meta.toml b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/routines/RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM/meta.toml new file mode 100644 index 00000000..46314232 --- /dev/null +++ b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/routines/RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM/meta.toml @@ -0,0 +1 @@ +name = "RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM" diff --git a/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/routines/RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM/routine.sql b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/routines/RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM/routine.sql new file mode 100644 index 00000000..7fd2032f --- /dev/null +++ b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/routines/RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM/routine.sql @@ -0,0 +1,3 @@ +CREATE OR REPLACE FUNCTION `{{ ref(name) }}`() RETURNS INT64 AS ( +202512 +); \ No newline at end of file diff --git a/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_delta/meta.toml b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_delta/meta.toml new file mode 100644 index 00000000..c0e944f9 --- /dev/null +++ b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_delta/meta.toml @@ -0,0 +1,2 @@ +name = "rescore_crux_202512_delta" +description = "Score delta for rescore rescore_crux_202512_delta" diff --git a/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_delta/view.sql b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_delta/view.sql new file mode 100644 index 00000000..b848e91e --- /dev/null +++ b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_delta/view.sql @@ -0,0 +1,32 @@ + +with scores as ( + SELECT + number, + old_scored_site_reports.score AS old_score, + new_scored_site_reports.score AS new_score, + old_scored_site_reports.is_global_1000 AS is_global_1000_old, + new_scored_site_reports.is_global_1000 AS is_global_1000_new, + old_scored_site_reports.is_sightline AS is_sightline_old, + new_scored_site_reports.is_sightline AS is_sightline_new, + old_scored_site_reports.is_japan_1000 AS is_japan_1000_old, + new_scored_site_reports.is_japan_1000 AS is_japan_1000_new, + old_scored_site_reports.is_japan_1000_mobile AS is_japan_1000_mobile_old, + new_scored_site_reports.is_japan_1000_mobile AS is_japan_1000_mobile_new + FROM `{{ ref('rescore_crux_202512_scored_site_reports') }}` as new_scored_site_reports + FULL OUTER JOIN `{{ ref('scored_site_reports') }}` AS old_scored_site_reports USING(number) + WHERE new_scored_site_reports.resolution = "" +) +SELECT + number, + old_score, + new_score, + is_global_1000_old, + is_global_1000_new, + is_sightline_old, + is_sightline_new, + is_japan_1000_old, + is_japan_1000_new, + is_japan_1000_mobile_old, + is_japan_1000_mobile_new, + new_score - old_score AS delta +FROM scores diff --git a/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_scored_site_reports/meta.toml b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_scored_site_reports/meta.toml new file mode 100644 index 00000000..bb1bdd30 --- /dev/null +++ b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_scored_site_reports/meta.toml @@ -0,0 +1 @@ +name = "rescore_crux_202512_scored_site_reports" diff --git a/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_scored_site_reports/view.sql b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_scored_site_reports/view.sql new file mode 100644 index 00000000..e9efdf48 --- /dev/null +++ b/jobs/webcompat-kb/data/sql/webcompat_knowledge_base/views/rescore_crux_202512_scored_site_reports/view.sql @@ -0,0 +1,108 @@ +WITH + host_categories AS ( + SELECT + `{{ ref('WEBCOMPAT_HOST') }}`(host) as webcompat_host, + {% for metric in metrics.values() if metric.host_min_ranks_condition() -%} + {{ metric.host_min_ranks_condition() }} AS is_{{ metric.name }}{{ ',' if not loop.last }} + {% endfor %} + FROM + `{{ ref('crux_imported.host_min_ranks') }}` + WHERE + yyyymm = `{{ ref('RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM') }}`() + GROUP BY + webcompat_host), + /* Individual score components for each bug. + + These should always match the logic in `{{ dataset }}.WEBCOMPAT_METRIC_SCORE_NO_SITE_RANK` + such that multiplying all the columns except severity score is equivalent to running that function.*/ scores AS ( + SELECT + number, + SUM( + IF + (weights.lookup_type = "severity" + AND weights.lookup_value = CAST(site_reports.severity AS string), weights.score, 0)) AS severity_score, + SUM( + IF + (weights.lookup_type = "impact" + AND weights.lookup_value = JSON_VALUE(site_reports.user_story, "$.impact"), weights.score, 0)) AS impact_score, + SUM( + IF + (weights.lookup_type = "platform" + AND weights.lookup_value IN UNNEST(SPLIT(JSON_VALUE(site_reports.user_story, "$.platform"))), weights.score, 0)) AS platform_score, + SUM( + IF + (weights.lookup_type = "configuration" + AND weights.lookup_value = IFNULL(JSON_VALUE(site_reports.user_story, "$.configuration"), "general"), weights.score, 0)) AS configuration_score, + SUM( + IF + (weights.lookup_type = "users_affected" + AND weights.lookup_value = IFNULL(JSON_VALUE(site_reports.user_story, "$.affects"), "all"), weights.score, 0)) AS affects_score, + SUM( + IF + (weights.lookup_type = "patch_applied" + AND weights.lookup_value = + IF + ("webcompat:sitepatch-applied" IN UNNEST(site_reports.keywords), + IF + ("webcompat:platform-bug" IN UNNEST(site_reports.keywords), "platform-bug", "site-bug"), "none"), weights.score, 0)) AS intervention_score, + SUM( + IF + (weights.lookup_type = "branch" + AND weights.lookup_value = IFNULL(JSON_VALUE(site_reports.user_story, "$.branch"), "release"), weights.score, 0)) AS branch_score, + FROM + `{{ ref('site_reports') }}` AS site_reports + CROSS JOIN + `{{ ref('dim_bug_score') }}` AS weights + GROUP BY + number), + +/* Computed scores for each bug + +These could be inlined, but it's slightly easier to read if they're computed in one place*/ +computed_scores AS ( + SELECT + number, + `{{ ref('WEBCOMPAT_METRIC_SCORE_NO_SITE_RANK') }}`(keywords, + user_story) AS triage_score_no_rank, + `{{ ref('WEBCOMPAT_METRIC_SCORE_SITE_RANK_MODIFIER') }}`(url, + `{{ ref('RESCORE_CRUX_202512_WEBCOMPAT_METRIC_YYYYMM') }}`()) AS site_rank_score + FROM + `{{ ref('site_reports') }}` AS site_reports +), + +site_report_scores AS ( + SELECT + site_reports.*, + severity_score, + impact_score, + platform_score, + configuration_score, + affects_score, + intervention_score, + site_rank_score, + branch_score, + triage_score_no_rank * site_rank_score AS triage_score, + {% for metric in metrics.values() if metric.site_reports_condition('host_categories') -%} + {{ metric.site_reports_condition('host_categories') }} AS is_{{ metric.name }}{{ ',' if not loop.last }} + {% endfor %} + FROM + `{{ ref('site_reports') }}` AS site_reports + JOIN + scores + USING + (number) + JOIN + computed_scores + USING + (number) + LEFT JOIN + host_categories + ON + host_categories.webcompat_host = `{{ ref('WEBCOMPAT_HOST') }}`(site_reports.url)) + +SELECT + site_report_scores.*, + -- This used to fall back to severity score + site_report_scores.triage_score AS score +FROM + site_report_scores