|
|
@@ -14,7 +14,6 @@ type ContributorWithUserId struct { |
|
|
|
UserId int64 |
|
|
|
IsAdmin bool |
|
|
|
RelAvatarLink string |
|
|
|
Email string |
|
|
|
} |
|
|
|
|
|
|
|
func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) { |
|
|
@@ -127,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 { |
|
|
@@ -144,12 +143,15 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { |
|
|
|
|
|
|
|
value, ok := contributorDistinctDict[user.Email] |
|
|
|
if !ok { |
|
|
|
contributorDistinctDict[user.Email] = ContributorWithUserId{ |
|
|
|
contributor, |
|
|
|
contributorDistinctDict[user.Email] = &ContributorWithUserId{ |
|
|
|
git.Contributor{ |
|
|
|
contributor.CommitCnt, |
|
|
|
user.Name, |
|
|
|
user.Email, |
|
|
|
}, |
|
|
|
user.ID, |
|
|
|
user.IsAdmin, |
|
|
|
user.RelAvatarLink(), |
|
|
|
user.Email, |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
@@ -159,12 +161,11 @@ 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, |
|
|
|
"", |
|
|
|
contributor.Email, |
|
|
|
} |
|
|
|
} else { |
|
|
|
value.CommitCnt += contributor.CommitCnt |
|
|
@@ -173,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) |
|
|
|
} |
|
|
@@ -188,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{}) { |
|
|
|