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,