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 22, 2022
1 parent 8393964 commit 19b6e53
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 65 deletions.
13 changes: 13 additions & 0 deletions auto_nag/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ 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"])


class Components:
"""Bugzilla components"""
Expand Down
21 changes: 0 additions & 21 deletions auto_nag/scripts/configs/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,27 +270,6 @@
],
"supervisor_skiplist": ["dcamp@mozilla.com"]
},
"no_severity": {
"max-years": 1,
"first-step": 2,
"second-step": 4,
"escalation-first": {
"default": {
"[0;+∞[": {
"supervisor": "self",
"days": ["Mon", "Tue", "Wed", "Thu", "Fri"]
}
}
},
"escalation-second": {
"default": {
"[0;+∞[": {
"supervisor": "n+1",
"days": ["Mon", "Thu"]
}
}
}
},
"p3_p4_p5": {
"months_lookup": 6
},
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
15 changes: 7 additions & 8 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.not_triaged import NotTriaged
from auto_nag.scripts.workflow.p1_no_assignee import P1NoAssignee
from auto_nag.scripts.workflow.triaged_no_severity import TriagedNoSeverity

# from .p1_no_activity import P1NoActivity
# from .p2_no_activity import P2NoActivity
Expand All @@ -16,8 +16,9 @@
class WorkflowMultiNag(MultiNaggers):
def __init__(self):
super(WorkflowMultiNag, self).__init__(
NoSeverity("first"),
NoSeverity("second"),
TriagedNoSeverity(),
NotTriaged("first"),
NotTriaged("second"),
# P1NoActivity(),
P1NoAssignee(),
# P2NoActivity(),
Expand All @@ -27,9 +28,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
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,88 @@
# 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):
"""Bugs that are not triaged"""

class NoSeverity(BzCleaner, Nag):
def __init__(self, typ, inactivity_days: int = 3):
def __init__(
self,
typ,
inactivity_days: int = 3,
oldest_bug_days: int = 360,
first_step_weeks: int = 2,
second_step_weeks: int = 4,
):
"""Constructor
Args:
typ: the mode that the tool should run with (first or second). Nag
emails will be sent only if `typ` is second.
inactivity_days: number of days that a bug should be inactive before
being considered.
oldest_bug_days: the max number of days since the creation of a bug
to be considered.
first_step_weeks: number of weeks to consider the bug for the the
first step.
second_step_weeks number of weeks to consider the bug for the the
second step.
"""
super(NoSeverity, self).__init__()
assert typ in {"first", "second"}
super().__init__()
self.date: datetime
self.typ = typ
self.lookup_first = utils.get_config(self.name(), "first-step", 2)
self.lookup_second = utils.get_config(self.name(), "second-step", 4)
self.oldest_bug_days = oldest_bug_days
self.lookup_first = first_step_weeks
self.lookup_second = second_step_weeks
self.escalation = Escalation(
self.people,
data=utils.get_config(self.name(), "escalation-{}".format(typ)),
data=ESCALATION_CONFIG[typ],
skiplist=utils.get_config("workflow", "supervisor_skiplist", []),
)
self.round_robin = RoundRobin.get_instance()
self.components_skiplist = utils.get_config("workflow", "components_skiplist")
self.components_skiplist = {
ComponentName.from_str(pc)
for pc in utils.get_config("workflow", "components_skiplist")
}
self.activity_date = lmdutils.get_date("today", inactivity_days)

def description(self):
return "Bugs without a severity or statuses set"
return "Bugs that are not triaged"

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">Severty definitions</a></li>
</ul>
</p>"""
return True

def get_extra_for_template(self):
return {
Expand All @@ -73,8 +107,7 @@ def columns(self):

def handle_bug(self, bug, data):
if (
# check if the product::component is in the list
utils.check_product_component(self.components_skiplist, bug)
ComponentName.from_bug(bug) in self.components_skiplist
or utils.get_last_no_bot_comment_date(bug) > self.activity_date
):
return None
Expand Down Expand Up @@ -115,21 +148,21 @@ def get_bz_params(self, date):
]
params = {
"include_fields": fields,
"keywords": "intermittent-failure",
"keywords": ["intermittent-failure", "triaged"],
"keywords_type": "nowords",
"email2": "wptsync@mozilla.bugs",
"emailreporter2": "1",
"emailtype2": "notequals",
"resolution": "---",
"f1": "creation_ts",
"o1": "greaterthan",
"v1": f"-{self.oldest_bug_days}d",
"f21": "bug_type",
"o21": "equals",
"v21": "defect",
"f22": "flagtypes.name",
"o22": "notsubstring",
"o22": "notequals",
"v22": "needinfo?",
"f23": "bug_severity",
"o23": "anyexact",
"v23": "--, n/a",
}
self.date = lmdutils.get_date_ymd(date)
first = f"-{self.lookup_first * 7}d"
Expand All @@ -144,9 +177,6 @@ def get_bz_params(self, date):
# ((second < creation < first) && pc never changed)
params.update(
{
"f2": "flagtypes.name",
"o2": "notequals",
"v2": "needinfo?",
"j3": "OR",
"f3": "OP",
"j4": "AND",
Expand Down Expand Up @@ -240,5 +270,5 @@ def get_bz_params(self, date):


if __name__ == "__main__":
NoSeverity("first").run()
NoSeverity("second").run()
NotTriaged("first").run()
NotTriaged("second").run()
Loading

0 comments on commit 19b6e53

Please sign in to comment.