Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nag to close leave-open bugs only when no deps or deps are all closed #850

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion auto_nag/scripts/leave_open_no_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"] == "":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could filter out closed bugs at query time directly

data.add(bug["id"])

bugids = set()
for info in bugs.values():
bugids.update(info["depends_on"])
bugids = list(bugids)
Comment on lines +55 to +58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
bugids = set()
for info in bugs.values():
bugids.update(info["depends_on"])
bugids = list(bugids)
bugids = list(set(sum((info["depends_on"] for info in bugs.values()), [])))

Comment on lines +55 to +58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename the variable dependencies_ids, so it's clearer what it refers to?

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
Comment on lines +68 to +74
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
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
return {bug_id: info for bug_id, info in bugs.items() if not (set(info["depends_on"]) & open_bugs)}


def get_bz_params(self, date):
fields = ["assigned_to", "triage_owner"]
fields = ["assigned_to", "triage_owner", "depends_on"]
params = {
"include_fields": fields,
"resolution": "---",
Expand All @@ -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()