From 16e45fd61bcd9a41747d7e11fa140688214bd2ac Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 15 Nov 2021 15:44:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AF=A6=E6=83=85top10?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=98=BE=E7=A4=BA=E7=94=A8=E6=88=B7=E5=A4=B4?= =?UTF-8?q?=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/repo_activity_custom.go | 7 +++++-- routers/api/v1/repo/repo_dashbord.go | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/models/repo_activity_custom.go b/models/repo_activity_custom.go index 7cfed2359..779c50687 100644 --- a/models/repo_activity_custom.go +++ b/models/repo_activity_custom.go @@ -11,8 +11,9 @@ import ( type ContributorWithUserId struct { git.Contributor - UserId int64 - IsAdmin bool + UserId int64 + IsAdmin bool + RelAvatarLink string } func GetRepoKPIStats(repo *Repository) (*git.RepoKPIStats, error) { @@ -146,6 +147,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { contributor, user.ID, user.IsAdmin, + user.RelAvatarLink(), } } else { @@ -159,6 +161,7 @@ func GetTop10Contributor(repoPath string) ([]ContributorWithUserId, error) { 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 0fcd70a99..81eb95f61 100644 --- a/routers/api/v1/repo/repo_dashbord.go +++ b/routers/api/v1/repo/repo_dashbord.go @@ -31,10 +31,11 @@ type ProjectsPeriodData struct { } type UserInfo struct { - User string `json:"user"` - Mode int `json:"mode"` - PR int64 `json:"pr"` - Commit int `json:"commit"` + User string `json:"user"` + Mode int `json:"mode"` + PR int64 `json:"pr"` + Commit int `json:"commit"` + RelAvatarLink string `json:"relAvatarLink"` } type ProjectLatestData struct { @@ -316,10 +317,11 @@ func GetProjectLatestStatistics(ctx *context.Context) { pr := models.GetPullCountByUserAndRepoId(repoIdInt, contributor.UserId) userInfo := UserInfo{ - User: contributor.Committer, - Commit: contributor.CommitCnt, - Mode: mode, - PR: pr, + User: contributor.Committer, + Commit: contributor.CommitCnt, + Mode: mode, + PR: pr, + RelAvatarLink: contributor.RelAvatarLink, } users = append(users, userInfo)