From e8c5271464fba035890cf833675dfdd35b2cdeac Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 23 Nov 2021 11:27:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3top10=20commit=E6=95=B0?= =?UTF-8?q?=E5=AF=B9=E4=B8=8D=E4=B8=8A=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/repo_activity_custom.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/models/repo_activity_custom.go b/models/repo_activity_custom.go index 539bb6b0d..7f343bdc6 100644 --- a/models/repo_activity_custom.go +++ b/models/repo_activity_custom.go @@ -126,12 +126,12 @@ func getRepoKPIStats(repoPath string, wikiPath string) (*git.RepoKPIStats, error } -func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { +func GetTop10Contributor(repoPath string) ([]*ContributorWithUserId, error) { contributors, err := git.GetContributors(repoPath) if err != nil { - return make([]ContributorWithUserId, 0), err + return make([]*ContributorWithUserId, 0), err } - contributorDistinctDict := make(map[string]ContributorWithUserId, 0) + contributorDistinctDict := make(map[string]*ContributorWithUserId, 0) if contributors != nil { for _, contributor := range contributors { if strings.Compare(contributor.Email, "") == 0 { @@ -143,7 +143,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { value, ok := contributorDistinctDict[user.Email] if !ok { - contributorDistinctDict[user.Email] = ContributorWithUserId{ + contributorDistinctDict[user.Email] = &ContributorWithUserId{ git.Contributor{ contributor.CommitCnt, user.Name, @@ -161,7 +161,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { } else { value, ok := contributorDistinctDict[contributor.Email] if !ok { - contributorDistinctDict[contributor.Email] = ContributorWithUserId{ + contributorDistinctDict[contributor.Email] = &ContributorWithUserId{ contributor, -1, false, @@ -174,7 +174,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { } } - v := make([]ContributorWithUserId, 0, len(contributorDistinctDict)) + v := make([]*ContributorWithUserId, 0, len(contributorDistinctDict)) for _, value := range contributorDistinctDict { v = append(v, value) } @@ -189,7 +189,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { return v[0:10], nil } } - return make([]ContributorWithUserId, 0), nil + return make([]*ContributorWithUserId, 0), nil } func setKeyContributerDict(contributorDistinctDict map[string]int, email string, keyContributorsDict map[string]struct{}) {