Browse Source

解决非协作者的贡献者权限获取不对问题

tags/v1.21.12.1
ychao_1983 4 years ago
parent
commit
91145c8e04
2 changed files with 13 additions and 1 deletions
  1. +4
    -1
      models/repo_activity_custom.go
  2. +9
    -0
      routers/api/v1/repo/repo_dashbord.go

+ 4
- 1
models/repo_activity_custom.go View File

@@ -11,7 +11,8 @@ import (


type ContributorWithUserId struct { type ContributorWithUserId struct {
git.Contributor git.Contributor
UserId int64
UserId int64
IsAdmin bool
} }


func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) { func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) {
@@ -144,6 +145,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) {
contributorDistinctDict[user.Email] = ContributorWithUserId{ contributorDistinctDict[user.Email] = ContributorWithUserId{
contributor, contributor,
user.ID, user.ID,
user.IsAdmin,
} }
} else { } else {


@@ -156,6 +158,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) {
contributorDistinctDict[contributor.Email] = ContributorWithUserId{ contributorDistinctDict[contributor.Email] = ContributorWithUserId{
contributor, contributor,
-1, -1,
false,
} }
} else { } else {
value.CommitCnt += contributor.CommitCnt value.CommitCnt += contributor.CommitCnt


+ 9
- 0
routers/api/v1/repo/repo_dashbord.go View File

@@ -151,6 +151,15 @@ func GetProjectLatestStatistics(ctx *context.Context) {


for _, contributor := range contributors { for _, contributor := range contributors {
mode := repository.GetCollaboratorMode(contributor.UserId) mode := repository.GetCollaboratorMode(contributor.UserId)
if mode == -1 {
if contributor.IsAdmin {
mode = int(models.AccessModeAdmin)
}
if contributor.UserId == repository.OwnerID {
mode = int(models.AccessModeOwner)
}
}

pr := models.GetPullCountByUserAndRepoId(repoIdInt, contributor.UserId) pr := models.GetPullCountByUserAndRepoId(repoIdInt, contributor.UserId)
userInfo := UserInfo{ userInfo := UserInfo{
User: contributor.Committer, User: contributor.Committer,


Loading…
Cancel
Save