Skip to content

Commit

Permalink
Add a new tool (to_triage): get daily email with bugs where priority … (
Browse files Browse the repository at this point in the history
#649)

* Add a new tool (to_triage): get daily email with bugs where priority is unset

* Update runner
  • Loading branch information
calixteman authored and sylvestre committed May 14, 2019
1 parent 9bbef1f commit 3e27dee
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 7 deletions.
11 changes: 7 additions & 4 deletions auto_nag/nag_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ def __init__(self):
def get_from():
return utils.get_config('auto_nag', 'from', 'release-mgmt@mozilla.com')

@staticmethod
def get_cc():
return set(utils.get_config('auto_nag', 'cc', []))
def get_cc(self):
cc = self.get_config('cc', None)
if cc is None:
cc = utils.get_config('auto_nag', 'cc', [])

return set(cc)

def get_priority(self, bug):
tracking = bug[self.tracking]
Expand Down Expand Up @@ -140,7 +143,7 @@ def send_mails(self, title, dryrun=False):
common = env.get_template('common.html')
login_info = utils.get_login_info()
From = Nag.get_from()
Default_Cc = Nag.get_cc()
Default_Cc = self.get_cc()
mails = self.prepare_mails()

for m in mails:
Expand Down
11 changes: 8 additions & 3 deletions auto_nag/round_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@


class RoundRobin(object):
def __init__(self, rr=None, people=None):
def __init__(self, rr=None, people=None, teams=None):
self.people = People() if people is None else people
self.all_calendars = []
self.feed(rr=rr)
self.feed(teams, rr=rr)
self.nicks = {}

def get_calendar(self, team, data):
Expand All @@ -29,14 +29,16 @@ def get_calendar(self, team, data):
res[strat] = Calendar.get(url, fallback, team, people=self.people)
return res

def feed(self, rr=None):
def feed(self, teams, rr=None):
self.data = {}
filenames = {}
if rr is None:
rr = {}
for team, path in utils.get_config(
'round-robin', 'teams', default={}
).items():
if teams is not None and team not in teams:
continue
with open('./auto_nag/scripts/configs/{}'.format(path), 'r') as In:
rr[team] = json.load(In)
filenames[team] = path
Expand All @@ -57,6 +59,9 @@ def feed(self, rr=None):
for pc, strategy in data['components'].items():
self.data[pc] = calendars[strategy]

def get_components(self):
return list(self.data.keys())

def get_nick(self, bzmail):
if bzmail not in self.nicks:

Expand Down
20 changes: 20 additions & 0 deletions auto_nag/scripts/configs/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -573,5 +573,25 @@
"sylvestre@mozilla.com",
"mcastelluccio@mozilla.com"
]
},
"to_triage":
{
"cc": [],
"max-years": 1,
"escalation":
{
"default":
{
"[0;+∞[":
{
"supervisor": "n+1",
"days": ["Mon", "Tue", "Wed", "Thu", "Fri"]
}
}
},
"teams":
[
"DOM:Workers & Storage"
]
}
}
82 changes: 82 additions & 0 deletions auto_nag/scripts/to_triage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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/.

from libmozdata import utils as lmdutils
from auto_nag.bzcleaner import BzCleaner
from auto_nag import utils
from auto_nag.escalation import Escalation
from auto_nag.nag_me import Nag
from auto_nag.round_robin import RoundRobin


class ToTriage(BzCleaner, Nag):
def __init__(self):
super(ToTriage, self).__init__()
self.escalation = Escalation(self.people, data=self.get_config('escalation'))
self.round_robin = RoundRobin(
people=self.people, teams=self.get_config('teams', [])
)
self.components = self.round_robin.get_components()

def description(self):
return 'Bugs to triage'

def nag_template(self):
return self.template()

def has_default_product(self):
return False

def has_product_component(self):
return True

def ignore_meta(self):
return True

def columns(self):
return ['component', 'id', 'summary', 'type']

def columns_nag(self):
return self.columns()

def handle_bug(self, bug, data):
bugid = str(bug['id'])
data[bugid] = {'type': bug['type']}
return bug

def set_people_to_nag(self, bug, buginfo):
priority = 'default'
if not self.filter_bug(priority):
return None

owner, _ = self.round_robin.get(bug, self.date)
real_owner = bug['triage_owner']
buginfo['type'] = bug['type']
self.add_triage_owner(owner, real_owner=real_owner)
if not self.add(owner, buginfo, priority=priority):
self.add_no_manager(buginfo['id'])
return bug

def get_bz_params(self, date):
self.date = lmdutils.get_date_ymd(date)
prods, comps = utils.get_products_components(self.components)
fields = ['triage_owner', 'type']
params = {
'include_fields': fields,
'product': list(prods),
'component': list(comps),
'resolution': '---',
'f1': 'priority',
'o1': 'equals',
'v1': '--',
'f2': 'flagtypes.name',
'o2': 'notequals',
'v2': 'needinfo?',
}

return params


if __name__ == '__main__':
ToTriage().run()
11 changes: 11 additions & 0 deletions auto_nag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,17 @@ def get_components(data):
return res


def get_products_components(data):
prods = set()
comps = set()
for pc in data:
if '::' in pc:
p, c = pc.split('::', 1)
prods.add(c)
comps.add(c)
return prods, comps


def ireplace(old, repl, text):
return re.sub('(?i)' + re.escape(old), lambda m: repl, text)

Expand Down
4 changes: 4 additions & 0 deletions runauto_nag_daily_py2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ python -m auto_nag.next_release
# Daily (but really runs during the soft freeze week)
python -m auto_nag.scripts.code_freeze_week -D yesterday

# Send a todo list to set priority
# Daily
python -m auto_nag.scripts.to_triage

# Nag triage fallback to update calendar
# Daily
python -m auto_nag.round_robin_fallback
Expand Down
27 changes: 27 additions & 0 deletions templates/to_triage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<p>The following {{ plural('bug has', data, pword='bugs have') }} no priority flag set and no pending needinfos (see the triage <a href="https://mozilla.github.io/bug-handling/triage-bugzilla#what-do-you-triage">documentation</a>):
<table {{ table_attrs }}>
<thead>
<tr>
<th>Component</th><th>Bug</th><th>Summary</th><th>Bug Type</th>
</tr>
</thead>
<tbody>
{% for i, (comp, bugid, summary, type) in enumerate(data) -%}
<tr {% if i % 2 == 0 %}bgcolor="#E0E0E0"{% endif -%}>
<td>
{{ comp | e }}
</td>
<td>
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id={{ bugid }}">{{ bugid }}</a>
</td>
<td>
{{ summary | e }}
</td>
<td>
{{ type | e }}
</td>
</tr>
{% endfor -%}
</tbody>
</table>
</p>

0 comments on commit 3e27dee

Please sign in to comment.