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

mozilla / relman-auto-nag / #5347

20 Nov 2024 09:06AM CUT coverage: 21.505%. Remained the same
#5347

push

coveralls-python

web-flow
Apply suggestions from code review

Co-authored-by: Suhaib Mujahid <suhaibmujahid@gmail.com>

426 of 2898 branches covered (14.7%)

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

1943 of 9035 relevant lines covered (21.51%)

0.22 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 typing import Any, 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__()
×
16
        self.sightline_ids = set()
×
17

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

33
        if bug["id"] in self.sightline_ids:
×
34
            if self.WHITEBOARD_ENTRY not in whiteboard:
×
35
                self.autofix_changes[bug_id] = {
×
36
                    "whiteboard": whiteboard + self.WHITEBOARD_ENTRY
37
                }
38
                return bug
×
39
        else:
NEW
40
            if self.WHITEBOARD_ENTRY in whiteboard:
×
NEW
41
                self.autofix_changes[bug_id] = {
×
42
                    "whiteboard": whiteboard.replace(self.WHITEBOARD_ENTRY, "")
43
                }
NEW
44
                return bug
×
45

46
        return None
×
47

48
    def get_bz_params(self, date) -> dict[str, Any]:
×
49
        fields = ["id", "summary", "whiteboard"]
×
50
        self.sightline_ids = self.get_sightline_bug_ids()
×
51
        # Get all bugs that either have, or should have, the [webcompat:sightline]
52
        # whiteboard entry
53
        return {
×
54
            "include_fields": fields,
55
            "j_top": "OR",
56
            "f1": "bug_id",
57
            "o1": "anyexact",
58
            "v1": ",".join(str(item) for item in self.sightline_ids),
59
            "f2": "status_whiteboard",
60
            "o2": "substring",
61
            "v2": self.WHITEBOARD_ENTRY,
62
        }
63

64
    def get_sightline_bug_ids(self) -> set[int]:
×
65
        project = "moz-fx-dev-dschubert-wckb"
×
66
        dataset = "webcompat_knowledge_base"
×
67

68
        client = gcp.get_bigquery_client(project, ["cloud-platform", "drive"])
×
69
        query = f"""
×
70
        SELECT number FROM `{project}.{dataset}.webcompat_topline_metric_site_reports` as bugs
71
        """
72

73
        return {row["number"] for row in client.query(query).result()}
×
74

75

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