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

mozilla / relman-auto-nag / #5394

20 Jan 2025 03:15PM CUT coverage: 21.2%. Remained the same
#5394

push

coveralls-python

web-flow
Update bugbot/rules/webcompat_score.py

426 of 2950 branches covered (14.44%)

0 of 1 new or added line 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

5
from typing import Any, Optional
×
6

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

10

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

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

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

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

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

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[bug_id] = {
×
36
                "cf_webcompat_score": self.scored_bugs[scored_bugs_key]
37
            }
38
            return bug
×
39

40
        return None
×
41

42
    def get_bz_params(self, date) -> dict[str, Any]:
×
43
        fields = ["id", "cf_webcompat_score"]
×
44
        self.scored_bugs = self.get_bug_scores()
×
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

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

71
        client = gcp.get_bigquery_client(project, ["cloud-platform", "drive"])
×
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

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

82

83
if __name__ == "__main__":
×
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