def _get_committers(self, annotated_frames, commits): # extract the unique committers and return their serialized sentry accounts committers = defaultdict(int) limit = 5 for annotated_frame in annotated_frames: if limit == 0: break for commit in annotated_frame['commits']: committers[commit.author.id] += limit limit -= 1 if limit == 0: break # organize them by this heuristic (first frame is worth 5 points, second is worth 4, etc.) sorted_committers = sorted(committers, key=committers.get) sentry_user_dict = get_users_for_commits(commits) user_dicts = [{ 'author': sentry_user_dict[author_id], 'commits': self._get_commits_committer(commits, author_id) } for author_id in sorted_committers] return user_dicts
def get_attrs(self, item_list, user): commits = Commit.objects.filter( id__in=[f.commit_id for f in item_list]).select_related('author') author_objs = get_users_for_commits(commits) commits_by_id = {commit.id: commit for commit in commits} result = {} for item in item_list: commit = commits_by_id[item.commit_id] result[item] = { 'user': author_objs.get(commit.author_id, {}), 'message': commit.message } return result
def get_attrs(self, item_list, user): author_objs = get_users_for_commits(item_list) repositories = list( Repository.objects.filter( id__in=[c.repository_id for c in item_list])) repository_objs = {} for repository in repositories: repository_objs[repository.id] = serialize(repository) result = {} for item in item_list: result[item] = { 'repository': repository_objs.get(item.repository_id, {}), 'user': author_objs.get(item.author_id, {}) } return result
def get_attrs(self, item_list, user): commits = list(Commit.objects.filter(id__in=[f.commit_id for f in item_list]).select_related('author')) author_objs = get_users_for_commits(commits) commits_by_id = {commit.id: commit for commit in commits} repo_names_by_id = dict(Repository.objects.filter( id__in=[commit.repository_id for commit in commits] ).values_list('id', 'name')) result = {} for item in item_list: commit = commits_by_id[item.commit_id] result[item] = { 'user': author_objs.get(commit.author_id, {}), 'message': commit.message, 'repository_name': repo_names_by_id.get(commit.repository_id) } return result