Esempio n. 1
0
def _get_committers(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, score 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)
    users_by_author = get_users_for_commits([c for c, _ in commits])

    user_dicts = [{
        'author': users_by_author.get(six.text_type(author_id)),
        'commits': _get_commits_committer(
            commits,
            author_id,
        )
    } for author_id in sorted_committers]

    return user_dicts
Esempio n. 2
0
    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")
        )
        users_by_author = 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": users_by_author.get(six.text_type(commit.author_id), {})
                if commit.author_id
                else {},
                "message": commit.message,
                "repository_name": repo_names_by_id.get(commit.repository_id),
            }

        return result
Esempio n. 3
0
def _get_committers(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, score in annotated_frame["commits"]:
            if not commit.author_id:
                continue
            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)
    users_by_author = get_users_for_commits([c for c, _ in commits])

    user_dicts = [{
        "author":
        users_by_author.get(str(author_id)),
        "commits": [(commit, score) for (commit, score) in commits
                    if commit.author_id == author_id],
    } for author_id in sorted_committers]

    return user_dicts
Esempio n. 4
0
def _get_committers(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, score 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)
    users_by_author = get_users_for_commits([c for c, _ in commits])

    user_dicts = [
        {
            'author': users_by_author.get(six.text_type(author_id)),
            'commits': _get_commits_committer(
                commits,
                author_id,
            )
        } for author_id in sorted_committers
    ]

    return user_dicts
Esempio n. 5
0
    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')
        )
        users_by_author = 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': users_by_author.get(six.text_type(commit.author_id), {})
                if commit.author_id else {},
                'message': commit.message,
                'repository_name': repo_names_by_id.get(commit.repository_id)
            }

        return result
Esempio n. 6
0
    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'))
        users_by_author = 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': users_by_author.get(six.text_type(commit.author_id),
                                            {}) if commit.author_id else {},
                'message': commit.message,
                'repository_name': repo_names_by_id.get(commit.repository_id)
            }

        return result