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

mozilla / relman-auto-nag / #4349

pending completion
#4349

push

coveralls-python

sosa-e
Revert "Minimizing config file"

This reverts commit 614159597.

564 of 3081 branches covered (18.31%)

24 of 24 new or added lines in 24 files covered. (100.0%)

1804 of 7980 relevant lines covered (22.61%)

0.23 hits per line

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

0.0
/auto_nag/scripts/warn_regressed_by.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 auto_nag import utils
×
6
from auto_nag.bzcleaner import BzCleaner
×
7

8

9
class WarnRegressedBy(BzCleaner):
×
10
    def __init__(self):
×
11
        super(WarnRegressedBy, self).__init__()
×
12
        self.regressions = {}
×
13
        self.threshold = self.get_config("threshold", 3)
×
14
        self.days = self.get_config("days_lookup", 14)
×
15
        self.step = 0
×
16

17
    def description(self):
×
18
        return "Bugs with more than {} regressions reported in the last {} days".format(
×
19
            self.threshold, self.days
20
        )
21

22
    def get_extra_for_template(self):
×
23
        return {"threshold": self.threshold, "days": self.days}
×
24

25
    def has_product_component(self):
×
26
        return self.step != 0
×
27

28
    def has_assignee(self):
×
29
        return self.step != 0
×
30

31
    def has_last_comment_time(self):
×
32
        return self.step != 0
×
33

34
    def columns(self):
×
35
        return [
×
36
            "id",
37
            "summary",
38
            "product",
39
            "component",
40
            "creation",
41
            "priority",
42
            "severity",
43
            "assignee",
44
            "last_comment",
45
        ]
46

47
    def handle_bug(self, bug, data):
×
48
        bugid = str(bug["id"])
×
49

50
        if self.step == 0:
×
51
            for reg_id in bug["regressed_by"]:
×
52
                reg_id = str(reg_id)
×
53
                if reg_id not in self.regressions:
×
54
                    self.regressions[reg_id] = [bugid]
×
55
                else:
56
                    self.regressions[reg_id].append(bugid)
×
57
        else:
58
            data[bugid] = {
×
59
                "creation": utils.get_human_lag(bug["creation_time"]),
60
                "priority": bug["priority"],
61
                "severity": bug["severity"],
62
            }
63

64
        return bug
×
65

66
    def to_warn(self):
×
67
        self.bugs_to_warn = []
×
68
        for reg_id, bids in self.regressions.items():
×
69
            if len(bids) >= self.threshold:
×
70
                self.bugs_to_warn.append(reg_id)
×
71

72
    def get_bz_params(self, date):
×
73
        if self.step == 0:
×
74
            start_date, _ = self.get_dates(date)
×
75
            fields = ["regressed_by"]
×
76
            params = {
×
77
                "include_fields": fields,
78
                "f1": "regressed_by",
79
                "o1": "isnotempty",
80
                "f2": "creation_ts",
81
                "o2": "greaterthan",
82
                "v2": start_date,
83
            }
84
        else:
85
            fields = ["creation_time", "priority", "severity"]
×
86
            params = {"include_fields": fields}
×
87

88
        return params
×
89

90
    def get_bugs(self, date="today", bug_ids=[]):
×
91
        bugs = super(WarnRegressedBy, self).get_bugs(date=date, bug_ids=bug_ids)
×
92
        self.to_warn()
×
93
        if self.bugs_to_warn:
×
94
            self.step = 1
×
95
            bugs = super(WarnRegressedBy, self).get_bugs(
×
96
                date=date, bug_ids=self.bugs_to_warn
97
            )
98
            return bugs
×
99

100
        return {}
×
101

102

103
if __name__ == "__main__":
×
104
    WarnRegressedBy().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