def _compute_commenters(self): res = defaultdict(dict) # Indexed by user, since we only display each user once. excluded_users = set(("SparkQA", "AmplabJenkins")) all_comments = sorted((self.comments_json or []) + (self.pr_comments_json or []), key=lambda c: c['created_at']) for comment in all_comments: if is_jenkins_command(comment['body']): continue # Skip comments that solely consist of Jenkins commands # If a user deletes their GitHub account, the 'user' field of their comments seems to # become 'null' in the JSON (although it points to the user info for the 'ghost' user # in other contexts). As a result, we have to guard against that here: user = (comment.get('user') or {}).get('login') if user is not None and user not in excluded_users: user_dict = res[user] user_dict['url'] = comment['html_url'] user_dict['avatar'] = comment['user']['avatar_url'] user_dict['date'] = comment['created_at'], user_dict['body'] = comment['body'] # Display at most 10 lines of context for comments left on diffs: user_dict['diff_hunk'] = '\n'.join( comment.get('diff_hunk', '').split('\n')[-10:]) user_dict['said_lgtm'] = (user_dict.get('said_lgtm') or re.search("lgtm", comment['body'], re.I) is not None) user_dict['asked_to_close'] = \ (user_dict.get('asked_to_close') or Issue.ASKED_TO_CLOSE_REGEX.search(comment['body']) is not None) return sorted(res.items(), key=lambda x: x[1]['date'], reverse=True)
def _compute_commenters(self): res = defaultdict( dict) # Indexed by user, since we only display each user once. excluded_users = set(("SparkQA", "AmplabJenkins")) all_comments = sorted( (self.comments_json or []) + (self.pr_comments_json or []), key=lambda c: c['created_at']) for comment in all_comments: if is_jenkins_command(comment['body']): continue # Skip comments that solely consist of Jenkins commands user = comment['user']['login'] if user not in excluded_users: user_dict = res[user] user_dict['url'] = comment['html_url'] user_dict['avatar'] = comment['user']['avatar_url'] user_dict['date'] = comment['created_at'], user_dict['body'] = comment['body'] # Display at most 10 lines of context for comments left on diffs: user_dict['diff_hunk'] = '\n'.join( comment.get('diff_hunk', '').split('\n')[-10:]) user_dict['said_lgtm'] = (user_dict.get('said_lgtm') or re.search("lgtm", comment['body'], re.I) is not None) user_dict['asked_to_close'] = \ (user_dict.get('asked_to_close') or Issue.ASKED_TO_CLOSE_REGEX.search(comment['body']) is not None) return sorted(res.items(), key=lambda x: x[1]['date'], reverse=True)
def _compute_commenters(self): res = defaultdict( dict) # Indexed by user, since we only display each user once. excluded_users = set(("SparkQA", "AmplabJenkins")) all_comments = sorted( (self.comments_json or []) + (self.pr_comments_json or []), key=lambda c: c['created_at']) for comment in all_comments: if is_jenkins_command(comment['body']): continue # Skip comments that solely consist of Jenkins commands # If a user deletes their GitHub account, the 'user' field of their comments seems to # become 'null' in the JSON (although it points to the user info for the 'ghost' user # in other contexts). As a result, we have to guard against that here: user = (comment.get('user') or {}).get('login') if user is not None and user not in excluded_users: user_dict = res[user] user_dict['url'] = comment['html_url'] user_dict['avatar'] = comment['user']['avatar_url'] user_dict['date'] = comment['created_at'], user_dict['body'] = comment['body'] # Display at most 10 lines of context for comments left on diffs: user_dict['diff_hunk'] = '\n'.join( comment.get('diff_hunk', '').split('\n')[-10:]) user_dict['said_lgtm'] = (user_dict.get('said_lgtm') or re.search("lgtm", comment['body'], re.I) is not None) user_dict['asked_to_close'] = \ (user_dict.get('asked_to_close') or Issue.ASKED_TO_CLOSE_REGEX.search(comment['body']) is not None) return sorted(res.items(), key=lambda x: x[1]['date'], reverse=True)
def _compute_commenters(self): res = defaultdict(dict) # Indexed by user, since we only display each user once. excluded_users = set(("SparkQA", "AmplabJenkins")) for comment in (self.comments_json or []): if is_jenkins_command(comment['body']): continue # Skip comments that solely consist of Jenkins commands user = comment['user']['login'] if user not in excluded_users: user_dict = res[user] user_dict['url'] = comment['html_url'] user_dict['avatar'] = comment['user']['avatar_url'] user_dict['date'] = comment['created_at'], user_dict['body'] = comment['body'] user_dict['said_lgtm'] = (user_dict.get('said_lgtm') or re.search("lgtm", comment['body'], re.I) is not None) user_dict['asked_to_close'] = \ (user_dict.get('asked_to_close') or Issue.ASKED_TO_CLOSE_REGEX.search(comment['body']) is not None) return sorted(res.items(), key=lambda x: x[1]['date'], reverse=True)