Skip to content

Commit

Permalink
Clear inactive assignee for old high-priority bugs without needinfo (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminmah authored Dec 10, 2024
1 parent c9b1d75 commit 83b2af4
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions bugbot/rules/assignee_no_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.

import collections
from datetime import datetime, timedelta

from libmozdata import utils as lmdutils

Expand All @@ -23,6 +24,7 @@ def __init__(self):
self.people = people.People.get_instance()
self.unassign_count = collections.defaultdict(int)
self.no_bugmail = True
self.one_year_ago = datetime.now() - timedelta(days=365)

self.extra_ni = {}

Expand Down Expand Up @@ -104,9 +106,13 @@ def add_action(self, bug):
# It's not paramount for triage owners to make an explicit decision here, it's enough for them
# to receive the notification about the unassignment from Bugzilla via email.
if (
bug["priority"] not in HIGH_PRIORITY
and bug["severity"] not in HIGH_SEVERITY
) or "stalled" in bug["keywords"]:
(
bug["priority"] not in HIGH_PRIORITY
and bug["severity"] not in HIGH_SEVERITY
)
or "stalled" in bug["keywords"]
or (bug["is_old_priority"] and bug["priority"] in HIGH_PRIORITY)
):
needinfo = None
autofix["comment"] = {
"body": "The bug assignee is inactive on Bugzilla, so the assignee is being reset."
Expand All @@ -126,12 +132,28 @@ def add_action(self, bug):

self.add_prioritized_action(bug, bug["triage_owner"], needinfo, autofix)

def get_priority_change_date(self, bug):
current_priority = bug["priority"]

for change in reversed(bug["history"]):
if (
change["field_name"] == "priority"
and change["added"] == current_priority
):
return datetime.strptime(change["when"], "%Y-%m-%dT%H:%M:%SZ")
return None

def handle_bug(self, bug, data):
bugid = str(bug["id"])
if "triage_owner_detail" not in bug:
logger.warning("Skip bug %s: no triage owner", bugid)
return None

priority_change_date = self.get_priority_change_date(bug)
is_old_priority = (
priority_change_date and priority_change_date < self.one_year_ago
)

data[bugid] = {
"assigned_to": bug["assigned_to"],
"triage_owner": bug["triage_owner"],
Expand All @@ -142,6 +164,7 @@ def handle_bug(self, bug, data):
"priority": bug["priority"],
"severity": bug["severity"],
"keywords": bug["keywords"],
"is_old_priority": is_old_priority,
}

return bug
Expand All @@ -158,6 +181,7 @@ def get_bz_params(self, date):
"priority",
"severity",
"keywords",
"history",
]
params = {
"include_fields": fields,
Expand Down

0 comments on commit 83b2af4

Please sign in to comment.