-
Notifications
You must be signed in to change notification settings - Fork 67
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
Updated not_landed to get user nicks in 1 call and removed the duplicate - Closes #1101 #2365
Open
Jubintgh
wants to merge
3
commits into
mozilla:master
Choose a base branch
from
Jubintgh:fix_notlanded
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,7 +252,7 @@ def attachment_handler(attachments, data): | |
|
||
return data | ||
|
||
def get_bz_userid(self, phids): | ||
def get_bz_users(self, phids): | ||
if not phids: | ||
return {} | ||
|
||
|
@@ -263,37 +263,18 @@ def get_bz_userid(self, phids): | |
return {} | ||
|
||
def handler(user, data): | ||
data[str(user["id"])] = user["name"] | ||
data[str(user["id"])] = user | ||
|
||
data = {} | ||
BugzillaUser( | ||
user_names=list(users.values()), | ||
include_fields=["id", "name"], | ||
include_fields=["id", "name", "nick"], | ||
user_handler=handler, | ||
user_data=data, | ||
).wait() | ||
|
||
return {phid: data[id] for phid, id in users.items()} | ||
|
||
def get_nicks(self, nicknames): | ||
def handler(user, data): | ||
data[user["name"]] = user["nick"] | ||
|
||
users = set(nicknames.values()) | ||
data = {} | ||
if users: | ||
BugzillaUser( | ||
user_names=list(users), | ||
include_fields=["name", "nick"], | ||
user_handler=handler, | ||
user_data=data, | ||
).wait() | ||
|
||
for bugid, name in nicknames.items(): | ||
nicknames[bugid] = (name, data[name]) | ||
|
||
return nicknames | ||
|
||
def get_bz_params(self, date): | ||
self.date = lmdutils.get_date_ymd(date) | ||
fields = ["flags", "depends_on"] | ||
|
@@ -330,33 +311,33 @@ def get_bugs(self, date="today", bug_ids=[]): | |
res = {} | ||
|
||
reviewers_phid = set() | ||
nicknames = {} | ||
bug_assignee_map = {} | ||
for bugid, data in bugs_patch.items(): | ||
reviewers_phid |= data["reviewers_phid"] | ||
assignee = bugs[bugid]["assigned_to"] | ||
if not assignee: | ||
assignee = max(data["author"], key=data["author"].get) | ||
nicknames[bugid] = assignee | ||
bug_assignee_map[bugid] = assignee | ||
|
||
bz_reviewers = self.get_bz_userid(reviewers_phid) | ||
bz_reviewers = self.get_bz_users(reviewers_phid) | ||
all_reviewers = set(bz_reviewers.keys()) | ||
nicknames = self.get_nicks(nicknames) | ||
Jubintgh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
for bugid, data in bugs_patch.items(): | ||
res[bugid] = d = bugs[bugid] | ||
self.extra_ni[bugid] = data["count"] | ||
assignee = d["assigned_to"] | ||
nickname = d["nickname"] | ||
|
||
if not assignee: | ||
assignee, nickname = nicknames[bugid] | ||
user_details = bz_reviewers[assignee] | ||
assignee = user_details["id"] | ||
nickname = user_details["nick"] | ||
|
||
if not assignee: | ||
continue | ||
|
||
self.add_auto_ni(bugid, {"mail": assignee, "nickname": nickname}) | ||
|
||
common = all_reviewers & data["reviewers_phid"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't |
||
common = all_reviewers["name"] & data["reviewers_phid"] | ||
if common: | ||
reviewer = random.choice(list(common)) | ||
self.add_auto_ni( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
bug_assignee_map
dict does not seem to be used anywhere. Do we need it after the changes in this PR?