Skip to content

Commit

Permalink
Support the new triaged keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaibmujahid committed Jul 19, 2022
1 parent ab7ceac commit 821db8e
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 10 deletions.
12 changes: 12 additions & 0 deletions auto_nag/component_triagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ def from_str(cls, pc: str) -> "ComponentName":

return cls(*splitted_name)

@classmethod
def from_bug(cls, bug: dict) -> "ComponentName":
"""Create an instance from a bug dictionary.
Args:
bug: a dictionary that have product and component keys
Returns:
An instance from the ComponentName class based on the provided bug.
"""
return cls(bug["product"], bug["component"])


@dataclass
class TriageOwner:
Expand Down
5 changes: 1 addition & 4 deletions auto_nag/scripts/to_triage.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_bz_params(self, date):
"include_fields": fields,
"product": list(prods),
"component": list(comps),
"keywords": "intermittent-failure",
"keywords": ["intermittent-failure", "triaged"],
"keywords_type": "nowords",
"email2": "wptsync@mozilla.bugs",
"emailreporter2": "1",
Expand All @@ -91,9 +91,6 @@ def get_bz_params(self, date):
"f2": "flagtypes.name",
"o2": "notsubstring",
"v2": "needinfo?",
"f3": "bug_severity",
"o3": "anyexact",
"v3": "--, n/a",
}

return params
Expand Down
12 changes: 6 additions & 6 deletions auto_nag/scripts/workflow/multi_nag.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from auto_nag.erroneous_bzmail import check_erroneous_bzmail
from auto_nag.multinaggers import MultiNaggers

from .no_severity import NoSeverity
from .p1_no_assignee import P1NoAssignee
from auto_nag.scripts.workflow.no_severity import NoSeverity
from auto_nag.scripts.workflow.not_triaged import NotTriaged
from auto_nag.scripts.workflow.p1_no_assignee import P1NoAssignee

# from .p1_no_activity import P1NoActivity
# from .p2_no_activity import P2NoActivity
Expand All @@ -18,6 +18,8 @@ def __init__(self):
super(WorkflowMultiNag, self).__init__(
NoSeverity("first"),
NoSeverity("second"),
NotTriaged("first"),
NotTriaged("second"),
# P1NoActivity(),
P1NoAssignee(),
# P2NoActivity(),
Expand All @@ -27,9 +29,7 @@ def description(self):
return "Bugs requiring special attention to help release management"

def title(self):
return "{} -- Severity and Priority Flags Alert".format(
self.date.strftime("%A %b %d")
)
return "{} -- Triage Alert".format(self.date.strftime("%A %b %d"))


if __name__ == "__main__":
Expand Down
3 changes: 3 additions & 0 deletions auto_nag/scripts/workflow/no_severity.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def get_bz_params(self, date):
"f23": "bug_severity",
"o23": "anyexact",
"v23": "--, n/a",
"f24": "keywords",
"o24": "anyexact",
"v24": "triaged",
}
self.date = lmdutils.get_date_ymd(date)
first = f"-{self.lookup_first * 7}d"
Expand Down
171 changes: 171 additions & 0 deletions auto_nag/scripts/workflow/not_triaged.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# 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 datetime import datetime

from libmozdata import utils as lmdutils

from auto_nag import utils
from auto_nag.bzcleaner import BzCleaner
from auto_nag.component_triagers import ComponentName
from auto_nag.escalation import Escalation
from auto_nag.nag_me import Nag
from auto_nag.round_robin import RoundRobin

ESCALATION_CONFIG = {
"first": {
"default": {
"[0;+∞[": {
"supervisor": "self",
"days": ["Mon", "Tue", "Wed", "Thu", "Fri"],
},
},
},
"second": {
"default": {
"[0;+∞[": {
"supervisor": "n+1",
"days": ["Mon", "Thu"],
},
},
},
}


class NotTriaged(BzCleaner, Nag):
"""Not triage bugs"""

def __init__(self, typ, first_step_weeks: int = 2, second_step_weeks: int = 4):
"""Constructor
Args:
typ
first_step_weeks
second_step_weeks
"""
super().__init__()
self.date: datetime
self.typ = typ
self.lookup_first = first_step_weeks
self.lookup_second = second_step_weeks
self.escalation = Escalation(
self.people,
data=ESCALATION_CONFIG[typ],
skiplist=utils.get_config("workflow", "supervisor_skiplist", []),
)
self.round_robin = RoundRobin.get_instance()
self.components_skiplist = {
ComponentName.from_str(pc)
for pc in utils.get_config("workflow", "components_skiplist")
}

def description(self):
return "Bugs that are not triaged"

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

def nag_preamble(self):
return True

def get_extra_for_template(self):
return {
"nweeks": self.lookup_first if self.typ == "first" else self.lookup_second
}

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 ["component", "id", "summary"]

def handle_bug(self, bug, data):
if ComponentName.from_bug(bug) in self.components_skiplist:
return None
return bug

def get_mail_to_auto_ni(self, bug):
if self.typ == "second":
return None

mail, nick = self.round_robin.get(bug, self.date)
if mail and nick:
return {"mail": mail, "nickname": nick}

return None

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

# don't nag in the first step (just a ni is enough)
if self.typ == "first":
return bug

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"]
params = {
"include_fields": fields,
"keywords": ["intermittent-failure", "triaged"],
"keywords_type": "nowords",
"email2": "wptsync@mozilla.bugs",
"emailreporter2": "1",
"emailtype2": "notequals",
"resolution": "---",
"f21": "bug_type",
"o21": "equals",
"v21": "defect",
"f22": "flagtypes.name",
"o22": "notsubstring",
"v22": "needinfo?",
}
self.date = lmdutils.get_date_ymd(date)
first = f"-{self.lookup_first * 7}d"
second = f"-{self.lookup_second * 7}d"
if self.typ == "first":
params.update(
{
"j14": "AND",
"f14": "OP",
"f15": "creation_ts",
"o15": "lessthaneq",
"v15": first,
"f16": "creation_ts",
"o16": "greaterthan",
"v16": second,
"f19": "CP",
}
)
else:
params.update(
{
"f12": "creation_ts",
"o12": "lessthaneq",
"v12": second,
}
)

return params


if __name__ == "__main__":
NotTriaged("first").run()
NotTriaged("second").run()
1 change: 1 addition & 0 deletions auto_nag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ def bz_ignore_case(s):


def check_product_component(data, bug):
"""TODO: drop in favour of using ComponentName"""
prod = bug["product"]
comp = bug["component"]
pc = prod + "::" + comp
Expand Down
37 changes: 37 additions & 0 deletions templates/not_triaged.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% if nag_preamble %}
<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">Severty definitions</a></li>
</ul>
</p>
{% endif %}

<p>
The following {{ plural('bug has', data, pword='bugs have') }} not triaged for the last {{ extra['nweeks'] }} {{ plural('week', extra['nweeks']) }}:
</p>
<table {{ table_attrs }}>
<thead>
<tr>
<th>Component</th><th>Bug</th><th>Summary</th>
</tr>
</thead>
<tbody>
{% for i, (comp, bugid, summary) 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>
</tr>
{% endfor -%}
</tbody>
</table>
{% if query_url_nag %}<p>See the query on <a href="{{ query_url_nag }}">Bugzilla</a>.</p>{% endif -%}
1 change: 1 addition & 0 deletions templates/not_triaged_needinfo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:{{ nickname }}, could you please triage this bug?

0 comments on commit 821db8e

Please sign in to comment.