mirror of
1
Fork 0

Add more stats tables (#29730)

Add `Tags`, `Branches` and `CommitStatus` to monitor/stats

(cherry picked from commit e5e2b2fcd7e8446f99e8eb61eef9efe2790220c8)
This commit is contained in:
Lunny Xiao 2024-03-12 19:21:09 +08:00 committed by Earl Warren
parent fc8799f269
commit 926367fe1d
No known key found for this signature in database
GPG Key ID: 0579CB2928A78A00
1 changed files with 6 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
asymkey_model "code.gitea.io/gitea/models/asymkey" asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/auth" "code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
issues_model "code.gitea.io/gitea/models/issues" issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/models/organization"
access_model "code.gitea.io/gitea/models/perm/access" access_model "code.gitea.io/gitea/models/perm/access"
@ -29,7 +30,8 @@ type Statistic struct {
Mirror, Release, AuthSource, Webhook, Mirror, Release, AuthSource, Webhook,
Milestone, Label, HookTask, Milestone, Label, HookTask,
Team, UpdateTask, Project, Team, UpdateTask, Project,
ProjectBoard, Attachment int64 ProjectBoard, Attachment,
Branches, Tags, CommitStatus int64
IssueByLabel []IssueByLabelCount IssueByLabel []IssueByLabelCount
IssueByRepository []IssueByRepositoryCount IssueByRepository []IssueByRepositoryCount
} }
@ -58,6 +60,9 @@ func GetStatistic(ctx context.Context) (stats Statistic) {
stats.Counter.Watch, _ = e.Count(new(repo_model.Watch)) stats.Counter.Watch, _ = e.Count(new(repo_model.Watch))
stats.Counter.Star, _ = e.Count(new(repo_model.Star)) stats.Counter.Star, _ = e.Count(new(repo_model.Star))
stats.Counter.Access, _ = e.Count(new(access_model.Access)) stats.Counter.Access, _ = e.Count(new(access_model.Access))
stats.Counter.Branches, _ = e.Count(new(git_model.Branch))
stats.Counter.Tags, _ = e.Where("is_draft=?", false).Count(new(repo_model.Release))
stats.Counter.CommitStatus, _ = e.Count(new(git_model.CommitStatus))
type IssueCount struct { type IssueCount struct {
Count int64 Count int64