-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathno_severity_nag.py
185 lines (160 loc) · 5.69 KB
/
no_severity_nag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import numpy
from libmozdata import utils as lmdutils
from bugbot import utils
from bugbot.bzcleaner import BzCleaner
from bugbot.escalation import Escalation
from bugbot.nag_me import Nag
from bugbot.round_robin import RoundRobin
class NoSeverityNag(BzCleaner, Nag):
def __init__(self, inactivity_days: int = 4):
"""Constructor
Args:
inactivity_days: number of days that a bug should be inactive before
being considered.
"""
super(NoSeverityNag, self).__init__()
self.lookup = utils.get_config(self.name(), "weeks-lookup", 4)
self.escalation = Escalation(
self.people,
data=utils.get_config(self.name(), "escalation"),
skiplist=utils.get_config("workflow", "supervisor_skiplist", []),
)
self.round_robin = RoundRobin.get_instance()
self.components_skiplist = utils.get_config("workflow", "components_skiplist")
self.activity_date = str(
numpy.busday_offset(lmdutils.get_date("today"), -inactivity_days)
)
def description(self):
return "Bugs without a severity or statuses set"
def nag_template(self):
return self.template()
def nag_preamble(self):
return """<p>
<ul>
<li><a href="https://firefox-source-docs.mozilla.org/bug-mgmt/policies/triage-bugzilla.html#why-triage">Why triage?</a></li>
<li><a href="https://firefox-source-docs.mozilla.org/bug-mgmt/policies/triage-bugzilla.html#what-do-you-triage">What do you triage?</a></li>
<li><a href="https://firefox-source-docs.mozilla.org/bug-mgmt/guides/priority.html">Priority definitions</a></li>
<li><a href="https://firefox-source-docs.mozilla.org/bug-mgmt/guides/severity.html">Severity definitions</a></li>
</ul>
</p>"""
def get_extra_for_template(self):
return {"nweeks": self.lookup}
def get_extra_for_needinfo_template(self):
return self.get_extra_for_template()
def get_extra_for_nag_template(self):
return self.get_extra_for_template()
def has_product_component(self):
return True
def ignore_meta(self):
return True
def columns(self):
return ["product", "component", "id", "summary"]
def handle_bug(self, bug, data):
if (
# check if the product::component is in the list
utils.check_product_component(self.components_skiplist, bug)
or utils.get_last_no_bot_comment_date(bug) > self.activity_date
):
return None
return bug
def get_mail_to_auto_ni(self, bug):
return None
def set_people_to_nag(self, bug, buginfo):
priority = "default"
if not self.filter_bug(priority):
return None
owners = self.round_robin.get(bug, self.date, only_one=False, has_nick=False)
real_owner = bug["triage_owner"]
self.add_triage_owner(owners, real_owner=real_owner)
if not self.add(owners, buginfo, priority=priority):
self.add_no_manager(buginfo["id"])
return bug
def get_bz_params(self, date):
fields = [
"triage_owner",
"flags",
"comments.creator",
"comments.creation_time",
]
lookup = f"-{self.lookup * 7}d"
params = {
"include_fields": fields,
"keywords": "intermittent-failure",
"keywords_type": "nowords",
"email2": "[email protected]",
"emailreporter2": "1",
"emailtype2": "notequals",
"resolution": "---",
"f31": "bug_type",
"o31": "equals",
"v31": "defect",
"f32": "flagtypes.name",
"o32": "notsubstring",
"v32": "needinfo?",
"f33": "bug_severity",
"o33": "anyexact",
"v33": "--, n/a",
"j2": "OR",
"f2": "OP",
"j3": "AND",
"f3": "OP",
"f4": "product",
"o4": "changedbefore",
"v4": lookup,
"n5": 1,
"f5": "product",
"o5": "changedafter",
"v5": lookup,
"n6": 1,
"f6": "component",
"o6": "changedafter",
"v6": lookup,
"f7": "CP",
"j8": "AND",
"f8": "OP",
"f9": "component",
"o9": "changedbefore",
"v9": lookup,
"n10": 1,
"f10": "product",
"o10": "changedafter",
"v10": lookup,
"n11": 1,
"f11": "component",
"o11": "changedafter",
"v11": lookup,
"f12": "CP",
"j13": "AND",
"f13": "OP",
"f14": "creation_ts",
"o14": "lessthaneq",
"v14": lookup,
"n15": 1,
"f15": "product",
"o15": "everchanged",
"n16": 1,
"f16": "component",
"o16": "everchanged",
"f17": "CP",
"f18": "CP",
"n20": 1,
"j20": "OR",
"f20": "OP",
"f21": "bug_severity",
"o21": "changedfrom",
"v21": "critical",
"f22": "bug_severity",
"o22": "changedfrom",
"v22": "major",
"f23": "bug_severity",
"o23": "changedfrom",
"v23": "blocker",
"f30": "CP",
}
self.date = lmdutils.get_date_ymd(date)
return params
if __name__ == "__main__":
NoSeverityNag().run()