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

mozilla / relman-auto-nag / #5338

14 Nov 2024 02:18PM CUT coverage: 21.505% (-0.1%) from 21.608%
#5338

push

coveralls-python

jgraham
Add a rule to sync [webcompat:sightline] whiteboard entry

This should be set on all bugs that are part of the webcompat metrics
set, and by no bugs that aren't.

This initial approach just gets all the bugs that are either in that
set or have the whiteboard entry, and implements the logic to update
them in the client. Given that we expect initially to have ~700 bugs
in that set, this means we need to set the maximum number of bugs to
update to something rather high.

426 of 2898 branches covered (14.7%)

0 of 48 new or added lines in 3 files covered. (0.0%)

1 existing line in 1 file now uncovered.

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

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 WebcompatSightline(BzCleaner):
×
NEW
12
    WHITEBOARD_ENTRY = "[webcompat:sightline]"
×
13

NEW
14
    def __init__(self):
×
NEW
15
        super().__init__()
×
NEW
16
        self.sightline_ids = set()
×
17

NEW
18
    def description(self) -> str:
×
NEW
19
        return "Web Compat site report in the sightline metric set"
×
20

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

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

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

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

NEW
45
        return None
×
46

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

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

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

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

74

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