• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / relman-auto-nag / #5388

20 Jan 2025 12:24PM CUT coverage: 21.2% (-0.06%) from 21.264%
#5388

push

coveralls-python

jgraham
Add webcompat_score rule

This sets the cf_webcompat_score field to match a value computed in BigQuery.

426 of 2950 branches covered (14.44%)

0 of 32 new or added lines in 1 file covered. (0.0%)

1943 of 9165 relevant lines covered (21.2%)

0.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/bugbot/rules/webcompat_score.py
1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
# You can obtain one at http://mozilla.org/MPL/2.0/.
4

NEW
5
from typing import Any, Optional
×
6

NEW
7
from bugbot import gcp
×
NEW
8
from bugbot.bzcleaner import BzCleaner
×
9

10

NEW
11
class WebcompatScore(BzCleaner):
×
NEW
12
    def __init__(self):
×
NEW
13
        super().__init__()
×
NEW
14
        self.scored_bugs = {}
×
15

NEW
16
    def description(self) -> str:
×
NEW
17
        return "Update WebCompat score fields"
×
18

NEW
19
    def filter_no_nag_keyword(self) -> bool:
×
NEW
20
        return False
×
21

NEW
22
    def has_default_products(self) -> bool:
×
NEW
23
        return False
×
24

NEW
25
    def handle_bug(
×
26
        self, bug: dict[str, Any], data: dict[str, Any]
27
    ) -> Optional[dict[str, Any]]:
NEW
28
        scored_bugs_key = bug["id"]
×
NEW
29
        bug_id = str(bug["id"])
×
30

NEW
31
        if (
×
32
            scored_bugs_key in self.scored_bugs
33
            and bug["cf_webcompat_score"] != self.scored_bugs[scored_bugs_key]
34
        ):
NEW
35
            self.autofix_changes[str(bug_id)] = {
×
36
                "cf_webcompat_score": self.scored_bugs[scored_bugs_key]
37
            }
NEW
38
            return bug
×
39

NEW
40
        return None
×
41

NEW
42
    def get_bz_params(self, date) -> dict[str, Any]:
×
NEW
43
        fields = ["id", "cf_webcompat_score"]
×
NEW
44
        self.scored_bugs = self.get_bug_scores()
×
NEW
45
        return {
×
46
            "include_fields": fields,
47
            "resolution": "---",
48
            "j_top": "OR",
49
            "f1": "OP",
50
            "f2": "product",
51
            "o2": "equals",
52
            "v2": "Web Compatibility",
53
            "f3": "component",
54
            "o3": "equals",
55
            "v3": "Site Reports",
56
            "f4": "CP",
57
            "f5": "OP",
58
            "f6": "product",
59
            "o6": "notequals",
60
            "v6": "Web Compatibility",
61
            "f7": "keywords",
62
            "o7": "equals",
63
            "v7": "webcompat:site-report",
64
            "f8": "CP",
65
        }
66

NEW
67
    def get_bug_scores(self) -> dict[int, str]:
×
NEW
68
        project = "moz-fx-dev-dschubert-wckb"
×
NEW
69
        dataset = "webcompat_knowledge_base"
×
70

NEW
71
        client = gcp.get_bigquery_client(project, ["cloud-platform", "drive"])
×
NEW
72
        query = f"""
×
73
        SELECT bugs.number, cast(buckets.score_bucket as string) as score_bucket FROM `{project}.{dataset}.site_reports_bugzilla_buckets` as buckets
74
        JOIN `{project}.{dataset}.bugzilla_bugs` as bugs ON bugs.number = buckets.number
75
        WHERE bugs.resolution = ""
76
        """
77

NEW
78
        return {
×
79
            row["number"]: row["score_bucket"] for row in client.query(query).result()
80
        }
81

82

NEW
83
if __name__ == "__main__":
×
NEW
84
    WebcompatScore().run()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc