Skip to content

Commit 1cd566b

Browse files
authored
Notify managers and release managers when there is a needinfo on a top crash without activity for a week (#2724)
1 parent bd40836 commit 1cd566b

File tree

4 files changed

+157
-0
lines changed

4 files changed

+157
-0
lines changed

bugbot/rules/topcrash_notify.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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 import utils
6+
from bugbot.bzcleaner import BzCleaner
7+
from bugbot.nag_me import Nag
8+
9+
10+
class TopcrashNotify(BzCleaner, Nag):
11+
def __init__(self, number_of_weeks: int = 1):
12+
"""Constructor
13+
14+
Args:
15+
number_of_weeks: Number of weeks to consider when looking for
16+
recent activity
17+
"""
18+
super(TopcrashNotify, self).__init__()
19+
self.nweeks = number_of_weeks
20+
21+
def description(self):
22+
return "Bugs with a ni on a bug with topcrash keyword without activity for the last {} {}".format(
23+
self.nweeks, utils.plural("week", self.nweeks)
24+
)
25+
26+
def get_extra_for_template(self):
27+
return {"nweeks": self.nweeks}
28+
29+
def get_extra_for_nag_template(self):
30+
return self.get_extra_for_template()
31+
32+
def has_last_comment_time(self):
33+
return True
34+
35+
def has_needinfo(self):
36+
return True
37+
38+
def columns(self):
39+
return ["id", "summary", "needinfos", "last_comment"]
40+
41+
def columns_nag(self):
42+
return ["id", "summary", "to", "from", "last_comment"]
43+
44+
def get_priority(self, bug):
45+
return "normal"
46+
47+
def set_people_to_nag(self, bug, buginfo):
48+
priority = self.get_priority(bug)
49+
if not self.filter_bug(priority):
50+
return None
51+
52+
has_manager = False
53+
for flag in bug["flags"]:
54+
if flag.get("name", "") == "needinfo" and flag["status"] == "?":
55+
requestee = flag["requestee"]
56+
buginfo["to"] = requestee
57+
moz_name = self.get_people().get_moz_name(flag["setter"])
58+
buginfo["from"] = moz_name if moz_name is not None else flag["setter"]
59+
if self.add(requestee, buginfo, priority=priority):
60+
has_manager = True
61+
62+
if not has_manager:
63+
self.add_no_manager(buginfo["id"])
64+
65+
return bug
66+
67+
def get_bz_params(self, date):
68+
fields = ["flags", "_custom"]
69+
params = {
70+
"include_fields": fields,
71+
"resolution": "---",
72+
"f1": "days_elapsed",
73+
"o1": "greaterthan",
74+
"v1": self.nweeks * 7,
75+
"f2": "flagtypes.name",
76+
"o2": "casesubstring",
77+
"v2": "needinfo?",
78+
"f3": "keywords",
79+
"o3": "anyexact",
80+
"v3": ["topcrash", "topcrash-startup"],
81+
"f4": "keywords",
82+
"o4": "nowords",
83+
"v4": ["meta", "stalled"],
84+
}
85+
86+
return params
87+
88+
89+
if __name__ == "__main__":
90+
TopcrashNotify().run()

configs/rules.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,5 +477,8 @@
477477
},
478478
"perfalert_resolved_regression": {
479479
"additional_receivers": ["[email protected]", "[email protected]"]
480+
},
481+
"topcrash_notify": {
482+
"additional_receivers": ["rm"]
480483
}
481484
}

templates/topcrash_notify.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<p>
2+
The following {{ plural('bug has', data, pword='bugs have') }} a needinfo, {{ plural('is a top crash', data, pword='are top crashes') }}, and {{ plural('has', data, pword='have') }} no activity for the last {{ extra['nweeks'] }} {{ plural('week', extra['nweeks']) }} (when the bug is red, then the needinfo is on a person with no manager):
3+
</p>
4+
<table {{ table_attrs }}>
5+
<thead>
6+
<tr>
7+
<th>Bug</th>
8+
<th>Summary</th>
9+
<th>Needinfos</th>
10+
<th>Last comment</th>
11+
</tr>
12+
</thead>
13+
<tbody>
14+
{% for i, (bugid, summary, needinfos, last_comment) in enumerate(data) -%}
15+
<tr {% if i % 2 == 0 %}bgcolor="#E0E0E0"
16+
{% endif -%}
17+
>
18+
<td {% if bugid in no_manager %}style="background:red;"{% endif %}>
19+
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id={{ bugid }}">{{ bugid }}</a>
20+
</td>
21+
<td>{{ summary | e }}</td>
22+
<td>
23+
<ul style="padding: 0; margin: 0">
24+
{% for ni in needinfos -%}
25+
<li>
26+
<a href="mailto:{{ ni }}">{{ ni | e }}</a>
27+
</li>
28+
{% endfor -%}
29+
</ul>
30+
</td>
31+
<td>{{ last_comment }}</td>
32+
</tr>
33+
{% endfor -%}
34+
</tbody>
35+
</table>

templates/topcrash_notify_nag.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<p>
2+
The following {{ plural('bug has', data, pword='bugs have') }} a needinfo, {{ plural('is a top crash', data, pword='are top crashes') }}, and {{ plural('has', data, pword='have') }} no activity for the last {{ extra['nweeks'] }} {{ plural('week', extra['nweeks']) }}:
3+
</p>
4+
<table {{ table_attrs }}>
5+
<thead>
6+
<tr>
7+
<th>Bug</th>
8+
<th>Summary</th>
9+
<th>Needinfo</th>
10+
<th>Last comment</th>
11+
</tr>
12+
</thead>
13+
<tbody>
14+
{% for i, (bugid, summary, to, from, last_comment) in enumerate(data) -%}
15+
<tr {% if i % 2 == 0 %}bgcolor="#E0E0E0"
16+
{% endif -%}
17+
>
18+
<td>
19+
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id={{ bugid }}">{{ bugid }}</a>
20+
</td>
21+
<td>{{ summary | e }}</td>
22+
<td>
23+
<a href="mailto:{{ to }}">{{ to }}</a> from <a href="mailto:{{ from }}">{{ from }}</a>
24+
</td>
25+
<td>{{ last_comment }}</td>
26+
</tr>
27+
{% endfor -%}
28+
</tbody>
29+
</table>

0 commit comments

Comments
 (0)