From 91145c8e049e99c227202fe42a654441fc029571 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 9 Nov 2021 14:08:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=9D=9E=E5=8D=8F=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E7=9A=84=E8=B4=A1=E7=8C=AE=E8=80=85=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=AF=B9=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 | 5 ++++- routers/api/v1/repo/repo_dashbord.go | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/models/repo_activity_custom.go b/models/repo_activity_custom.go index 698436e2a..7cfed2359 100644 --- a/models/repo_activity_custom.go +++ b/models/repo_activity_custom.go @@ -11,7 +11,8 @@ import ( type ContributorWithUserId struct { git.Contributor - UserId int64 + UserId int64 + IsAdmin bool } func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) { @@ -144,6 +145,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { contributorDistinctDict[user.Email] = ContributorWithUserId{ contributor, user.ID, + user.IsAdmin, } } else { @@ -156,6 +158,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { contributorDistinctDict[contributor.Email] = ContributorWithUserId{ contributor, -1, + false, } } else { value.CommitCnt += contributor.CommitCnt diff --git a/routers/api/v1/repo/repo_dashbord.go b/routers/api/v1/repo/repo_dashbord.go index d9be6d5a7..6759470fb 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -151,6 +151,15 @@ func GetProjectLatestStatistics(ctx *context.Context) { for _, contributor := range contributors { 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) userInfo := UserInfo{ User: contributor.Committer,