diff --git a/auto_nag/scripts/leave_open_no_activity.py b/auto_nag/scripts/leave_open_no_activity.py index 30a1464c4..8c11935f7 100644 --- a/auto_nag/scripts/leave_open_no_activity.py +++ b/auto_nag/scripts/leave_open_no_activity.py @@ -2,6 +2,8 @@ # 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.bugzilla import Bugzilla + from auto_nag import utils from auto_nag.bzcleaner import BzCleaner from auto_nag.people import People @@ -40,8 +42,39 @@ def get_mail_to_auto_ni(self, bug): return None + def handle_bug(self, bug, data): + bugid = str(bug["id"]) + data[bugid] = {"id": bugid, "depends_on": bug["depends_on"]} + return bug + + def filter_deps(self, bugs): + def handler(bug, data): + if bug["resolution"] == "": + data.add(bug["id"]) + + bugids = set() + for info in bugs.values(): + bugids.update(info["depends_on"]) + bugids = list(bugids) + open_bugs = set() + + Bugzilla( + bugids=bugids, + include_fields=["id", "resolution"], + bughandler=handler, + bugdata=open_bugs, + ).get_data().wait() + + to_fix = {} + for bugid, info in bugs.items(): + deps = set(info["depends_on"]) + if not (deps & open_bugs): + to_fix[bugid] = info + + return to_fix + def get_bz_params(self, date): - fields = ["assigned_to", "triage_owner"] + fields = ["assigned_to", "triage_owner", "depends_on"] params = { "include_fields": fields, "resolution": "---", @@ -61,6 +94,12 @@ def get_bz_params(self, date): return params + def get_bugs(self, date="today", bug_ids=[]): + bugs = super(LeaveOpenNoActivity, self).get_bugs(date=date, bug_ids=bug_ids) + bugs = self.filter_deps(bugs) + + return bugs + if __name__ == "__main__": LeaveOpenNoActivity().run()