Browse Source

解决top10 commit数对不上的问题

tags/v1.21.12.1
ychao_1983 4 years ago
parent
commit
e8c5271464
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      models/repo_activity_custom.go

+ 7
- 7
models/repo_activity_custom.go View File

@@ -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{}) {


Loading…
Cancel
Save