mirror of
https://github.com/go-gitea/gitea
synced 2025-07-19 08:48:37 +00:00
Add top author stats to activity page (#9615)
This commit is contained in:
@@ -19,6 +19,7 @@ type ActivityAuthorData struct {
|
||||
Name string `json:"name"`
|
||||
Login string `json:"login"`
|
||||
AvatarLink string `json:"avatar_link"`
|
||||
HomeLink string `json:"home_link"`
|
||||
Commits int64 `json:"commits"`
|
||||
}
|
||||
|
||||
@@ -91,12 +92,20 @@ func GetActivityStatsTopAuthors(repo *Repository, timeFrom time.Time, count int)
|
||||
return nil, nil
|
||||
}
|
||||
users := make(map[int64]*ActivityAuthorData)
|
||||
for k, v := range code.Authors {
|
||||
if len(k) == 0 {
|
||||
var unknownUserID int64
|
||||
unknownUserAvatarLink := NewGhostUser().AvatarLink()
|
||||
for _, v := range code.Authors {
|
||||
if len(v.Email) == 0 {
|
||||
continue
|
||||
}
|
||||
u, err := GetUserByEmail(k)
|
||||
u, err := GetUserByEmail(v.Email)
|
||||
if u == nil || IsErrUserNotExist(err) {
|
||||
unknownUserID--
|
||||
users[unknownUserID] = &ActivityAuthorData{
|
||||
Name: v.Name,
|
||||
AvatarLink: unknownUserAvatarLink,
|
||||
Commits: v.Commits,
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
@@ -107,10 +116,11 @@ func GetActivityStatsTopAuthors(repo *Repository, timeFrom time.Time, count int)
|
||||
Name: u.DisplayName(),
|
||||
Login: u.LowerName,
|
||||
AvatarLink: u.AvatarLink(),
|
||||
Commits: v,
|
||||
HomeLink: u.HomeLink(),
|
||||
Commits: v.Commits,
|
||||
}
|
||||
} else {
|
||||
user.Commits += v
|
||||
user.Commits += v.Commits
|
||||
}
|
||||
}
|
||||
v := make([]*ActivityAuthorData, 0)
|
||||
@@ -119,7 +129,7 @@ func GetActivityStatsTopAuthors(repo *Repository, timeFrom time.Time, count int)
|
||||
}
|
||||
|
||||
sort.Slice(v, func(i, j int) bool {
|
||||
return v[i].Commits < v[j].Commits
|
||||
return v[i].Commits > v[j].Commits
|
||||
})
|
||||
|
||||
cnt := count
|
||||
|
Reference in New Issue
Block a user