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

mozilla / relman-auto-nag / #5570

09 Sep 2025 04:00PM UTC coverage: 20.81% (+0.01%) from 20.797%
#5570

push

coveralls-python

web-flow
Return query dict directly

426 of 3022 branches covered (14.1%)

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

1 existing line in 1 file now uncovered.

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

5
from dataclasses import dataclass
×
6
from typing import Any, Mapping, Optional
×
7

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

11

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

17

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

23

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

29
    def description(self) -> str:
×
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

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

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

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

56
        return None
×
57

58
    def get_bz_params(self, date) -> dict[str, Any]:
×
59
        fields = ["id", "summary", "whiteboard"]
×
60
        self.metric_bugs = self.get_metric_bugs()
×
61
        # Get all bugs that either have, or should have, the [webcompat:sightline]
62
        # whiteboard entry
NEW
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

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

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

78
        for metric in metrics:
×
79
            fields.append(metric.field)
×
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

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

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