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

mozilla / relman-auto-nag / #5571

09 Sep 2025 04:37PM UTC coverage: 20.81% (-0.03%) from 20.835%
#5571

push

coveralls-python

web-flow
Add [webcompat:japan] to whiteboard for bugs in Japan Top 1000 (#2697)

426 of 3022 branches covered (14.1%)

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

1943 of 9337 relevant lines covered (20.81%)

0.21 hits per line

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

0.0
/bugbot/rules/webcompat_sightline.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 dataclasses import dataclass
×
NEW
6
from typing import Any, Mapping, Optional
×
7

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

11

NEW
12
@dataclass(frozen=True)
×
NEW
13
class MetricType:
×
NEW
14
    field: str
×
NEW
15
    whiteboard_entry: str
×
16

17

NEW
18
metrics = [
×
19
    MetricType("is_sightline", "[webcompat:sightline]"),
20
    MetricType("is_japan_1000", "[webcompat:japan]"),
21
]
22

23

NEW
24
class WebcompatSightline(BzCleaner):
×
25
    def __init__(self):
×
26
        super().__init__()
×
NEW
27
        self.metric_bugs = {}
×
28

29
    def description(self) -> str:
×
NEW
30
        return "Bugs with the [webcompat:<metric name>] whiteboard tag updated"
×
31

32
    def filter_no_nag_keyword(self) -> bool:
×
33
        return False
×
34

35
    def has_default_products(self) -> bool:
×
36
        return False
×
37

38
    def handle_bug(
×
39
        self, bug: dict[str, Any], data: dict[str, Any]
40
    ) -> Optional[dict[str, Any]]:
41
        bug_id = str(bug["id"])
×
42
        whiteboard = bug["whiteboard"]
×
43

NEW
44
        bug_metrics = self.metric_bugs[bug["id"]]
×
45

NEW
46
        for metric, include in bug_metrics.items():
×
NEW
47
            if include and metric.whiteboard_entry not in whiteboard:
×
NEW
48
                whiteboard += metric.whiteboard_entry
×
NEW
49
            elif not include and metric.whiteboard_entry in whiteboard:
×
NEW
50
                whiteboard = whiteboard.replace(metric.whiteboard_entry, "")
×
51

NEW
52
        if whiteboard != bug["whiteboard"]:
×
NEW
53
            self.autofix_changes[bug_id] = {"whiteboard": whiteboard}
×
NEW
54
            return bug
×
55

56
        return None
×
57

58
    def get_bz_params(self, date) -> dict[str, Any]:
×
59
        fields = ["id", "summary", "whiteboard"]
×
NEW
60
        self.metric_bugs = self.get_metric_bugs()
×
61
        # Get all bugs that either have, or should have, the [webcompat:sightline]
62
        # whiteboard entry
63
        return {
×
64
            "include_fields": fields,
65
            "j_top": "OR",
66
            "f1": "bug_id",
67
            "o1": "anyexact",
68
            "v1": ",".join(str(item) for item in self.metric_bugs.keys()),
69
        }
70

NEW
71
    def get_metric_bugs(self) -> Mapping[int, Mapping[MetricType, bool]]:
×
72
        project = "moz-fx-dev-dschubert-wckb"
×
73
        dataset = "webcompat_knowledge_base"
×
74

NEW
75
        fields = []
×
NEW
76
        conditions = []
×
77

NEW
78
        for metric in metrics:
×
NEW
79
            fields.append(metric.field)
×
NEW
80
            conditions.append(
×
81
                f"""({metric.field} != CONTAINS_SUBSTR(bugs.whiteboard, "{metric.whiteboard_entry}"))"""
82
            )
83

84
        client = gcp.get_bigquery_client(project, ["cloud-platform", "drive"])
×
85
        query = f"""
×
86
        SELECT number, {", ".join(fields)} FROM `{project}.{dataset}.scored_site_reports` as bugs
87
        WHERE bugs.resolution = "" AND ({" OR ".join(conditions)})
88
        """
89

NEW
90
        results = {}
×
NEW
91
        for row in client.query(query).result():
×
NEW
92
            result = {metric: row[metric.field] for metric in metrics}
×
NEW
93
            results[row.number] = result
×
94

NEW
95
        return results
×
96

97

98
if __name__ == "__main__":
×
99
    WebcompatSightline().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