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

mozilla / relman-auto-nag / #5374

12 Dec 2024 03:22PM CUT coverage: 21.196% (-0.08%) from 21.274%
#5374

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 34 new or added lines in 1 file covered. (0.0%)

1943 of 9167 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.autofix_changes = {}
×
NEW
15
        self.scored_bugs = {}
×
16

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

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

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

NEW
26
    def get_autofix_change(self) -> dict[str, Any]:
×
NEW
27
        return self.autofix_changes
×
28

NEW
29
    def handle_bug(
×
30
        self, bug: dict[str, Any], data: dict[str, Any]
31
    ) -> Optional[dict[str, Any]]:
NEW
32
        bug_id = bug["id"]
×
33

NEW
34
        if (
×
35
            bug_id in self.scored_bugs
36
            and bug["cf_webcompat_score"] != self.scored_bugs[bug_id]
37
        ):
NEW
38
            self.autofix_changes[bug_id] = {
×
39
                "cf_webcompat_score": self.scored_bugs[bug_id]
40
            }
NEW
41
            return bug
×
42

NEW
43
        return None
×
44

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

NEW
71
    def get_bug_data(self) -> dict[int, str]:
×
NEW
72
        project = "moz-fx-dev-dschubert-wckb"
×
NEW
73
        dataset = "webcompat_knowledge_base"
×
74

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

NEW
82
        return {
×
83
            row["number"]: row["score_bucket"] for row in client.query(query).result()
84
        }
85

86

NEW
87
if __name__ == "__main__":
×
NEW
88
    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