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

mozilla / relman-auto-nag / #5541

06 Aug 2025 02:54PM UTC coverage: 21.015% (-0.007%) from 21.022%
#5541

push

coveralls-python

jgraham
Update webcompat_sightline rule to only query bugs that will change

This was failing because bugzilla was rejecting the query.

Since we now have the whiteboard data in BigQuery we can change the
implementation to get a list of bug ids that had incorrect data at the
time of last BQ import, and only query those bugs from bugzilla. This
makes the bugzilla query much shorter, and so less likely to run into
API limits.

426 of 2994 branches covered (14.23%)

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

1942 of 9241 relevant lines covered (21.02%)

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 typing import Any, Mapping, Optional
×
6

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

10

11
class WebcompatSightline(BzCleaner):
×
12
    WHITEBOARD_ENTRY = "[webcompat:sightline]"
×
13

14
    def __init__(self):
×
15
        super().__init__()
×
NEW
16
        self.sightline_data = {}
×
17

18
    def description(self) -> str:
×
19
        return "Bugs with the [webcompat:sightline] whiteboard tag updated"
×
20

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

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

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

NEW
33
        if bug["id"] not in self.sightline_data:
×
NEW
34
            return None
×
35

NEW
36
        is_sightline = self.sightline_data[bug["id"]]
×
NEW
37
        has_whiteboard = self.WHITEBOARD_ENTRY in whiteboard
×
NEW
38
        if is_sightline and not has_whiteboard:
×
NEW
39
            self.autofix_changes[bug_id] = {
×
40
                "whiteboard": whiteboard + self.WHITEBOARD_ENTRY
41
            }
NEW
42
            return bug
×
NEW
43
        if not is_sightline and has_whiteboard:
×
NEW
44
            self.autofix_changes[bug_id] = {
×
45
                "whiteboard": whiteboard.replace(self.WHITEBOARD_ENTRY, "")
46
            }
NEW
47
            return bug
×
48

49
        return None
×
50

51
    def get_bz_params(self, date) -> dict[str, Any]:
×
52
        fields = ["id", "summary", "whiteboard"]
×
NEW
53
        self.sightline_data = self.get_sightline_bug_data()
×
NEW
54
        return {"include_fields": fields, "id": list(self.sightline_data.keys())}
×
55
        return fields
56

NEW
57
    def get_sightline_bug_data(self) -> Mapping[int, bool]:
×
58
        project = "moz-fx-dev-dschubert-wckb"
×
59
        dataset = "webcompat_knowledge_base"
×
60

61
        client = gcp.get_bigquery_client(project, ["cloud-platform", "drive"])
×
62
        query = f"""
×
63
        SELECT number, bugs.is_sightline FROM `{project}.{dataset}.scored_site_reports` as bugs
64
        WHERE (bugs.is_sightline AND NOT CONTAINS_SUBSTR(bugs.whiteboard, "{self.WHITEBOARD_ENTRY}"))
65
          OR (NOT bugs.is_sightline AND CONTAINS_SUBSTR(bugs.whiteboard, "{self.WHITEBOARD_ENTRY}"))
66
        """
67

NEW
68
        return {
×
69
            row["number"]: row["is_sightline"] for row in client.query(query).result()
70
        }
71

72

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