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

mozilla / relman-auto-nag / #4952

04 Mar 2024 10:45AM CUT coverage: 21.779% (-0.01%) from 21.79%
#4952

push

coveralls-python

web-flow
Update bugbot/rules/worksforme.py

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

716 of 3602 branches covered (19.88%)

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

1 existing line in 1 file now uncovered.

1927 of 8848 relevant lines covered (21.78%)

0.22 hits per line

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

0.0
/bugbot/rules/worksforme.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 bugbot.bugbug_utils import get_bug_ids_classification
×
6
from bugbot.bzcleaner import BzCleaner
×
7
from bugbot.utils import nice_round
×
8

9

10
class WorksForMe(BzCleaner):
×
11
    def __init__(self, confidence_threshold: float = 0.9):
×
12
        """
13
        Initialize the WorksForMe class.
14

15
        Args:
16
            confidence_threshold: The confidence threshold for
17
                considering a bug as a worksforme bug.
18
        """
19
        super().__init__()
×
20
        self.confidence_threshold = confidence_threshold
×
21

22
    def description(self):
×
NEW
23
        return "[Using ML] Bugs that could be resolved as WORKSFORME"
×
24

25
    def columns(self):
×
26
        return ["id", "summary", "confidence", "autofixed"]
×
27

28
    def get_bz_params(self, date):
×
29
        start_date, _ = self.get_dates(date)
×
30

31
        params = {
×
32
            "resolution": "---",
33
            "cf_last_resolved": "---",
34
            "f1": "creation_ts",
35
            "o1": "greaterthan",
36
            "v1": start_date,
37
            "f2": "resolution",
38
            "o2": "notequals",
39
            "v2": "WORKSFORME",
40
        }
41

42
        return params
×
43

44
    def get_bugs(self, date="today", bug_ids=[]):
×
45
        raw_bugs = super().get_bugs(date=date, bug_ids=bug_ids, chunk_size=7000)
×
46

47
        if len(raw_bugs) == 0:
×
48
            return {}
×
49

50
        bug_ids = list(raw_bugs.keys())
×
51

52
        bugs = get_bug_ids_classification("worksforme", bug_ids)
×
53

54
        results = {}
×
55

56
        for bug_id, bug_data in bugs.items():
×
57
            if not bug_data.get("available", True):
×
58
                # The bug was not available, it was either removed or is a
59
                # security bug
60
                continue
×
61

62
            bug = raw_bugs[bug_id]
×
63
            prob = bug_data["prob"]
×
64

65
            if prob[1] < 0.2:
×
66
                continue
×
67

68
            results[bug_id] = {
×
69
                "id": bug_id,
70
                "summary": bug["summary"],
71
                "confidence": nice_round(prob[1]),
72
                "autofixed": prob[1] >= self.confidence_threshold,
73
            }
74

75
        return results
×
76

77

78
if __name__ == "__main__":
×
79
    WorksForMe().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