@@ -18,28 +18,30 @@ type Statistic struct {
1818 Comment , Oauth , Follow ,
1919 Mirror , Release , LoginSource , Webhook ,
2020 Milestone , Label , HookTask ,
21- Team , UpdateTask , Attachment int64
21+ Team , UpdateTask , Project ,
22+ ProjectBoard , Attachment int64
2223 }
2324}
2425
2526// GetStatistic returns the database statistics
2627func GetStatistic () (stats Statistic ) {
28+ e := db .GetEngine (db .DefaultContext )
2729 stats .Counter .User = CountUsers ()
2830 stats .Counter .Org = CountOrganizations ()
29- stats .Counter .PublicKey , _ = db . GetEngine ( db . DefaultContext ) .Count (new (PublicKey ))
31+ stats .Counter .PublicKey , _ = e .Count (new (PublicKey ))
3032 stats .Counter .Repo = CountRepositories (true )
31- stats .Counter .Watch , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Watch ))
32- stats .Counter .Star , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Star ))
33- stats .Counter .Action , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Action ))
34- stats .Counter .Access , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Access ))
33+ stats .Counter .Watch , _ = e .Count (new (Watch ))
34+ stats .Counter .Star , _ = e .Count (new (Star ))
35+ stats .Counter .Action , _ = e .Count (new (Action ))
36+ stats .Counter .Access , _ = e .Count (new (Access ))
3537
3638 type IssueCount struct {
3739 Count int64
3840 IsClosed bool
3941 }
4042 issueCounts := []IssueCount {}
4143
42- _ = db . GetEngine ( db . DefaultContext ) .Select ("COUNT(*) AS count, is_closed" ).Table ("issue" ).GroupBy ("is_closed" ).Find (& issueCounts )
44+ _ = e .Select ("COUNT(*) AS count, is_closed" ).Table ("issue" ).GroupBy ("is_closed" ).Find (& issueCounts )
4345 for _ , c := range issueCounts {
4446 if c .IsClosed {
4547 stats .Counter .IssueClosed = c .Count
@@ -50,17 +52,19 @@ func GetStatistic() (stats Statistic) {
5052
5153 stats .Counter .Issue = stats .Counter .IssueClosed + stats .Counter .IssueOpen
5254
53- stats .Counter .Comment , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Comment ))
55+ stats .Counter .Comment , _ = e .Count (new (Comment ))
5456 stats .Counter .Oauth = 0
55- stats .Counter .Follow , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Follow ))
56- stats .Counter .Mirror , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Mirror ))
57- stats .Counter .Release , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Release ))
57+ stats .Counter .Follow , _ = e .Count (new (Follow ))
58+ stats .Counter .Mirror , _ = e .Count (new (Mirror ))
59+ stats .Counter .Release , _ = e .Count (new (Release ))
5860 stats .Counter .LoginSource = login .CountSources ()
59- stats .Counter .Webhook , _ = db .GetEngine (db .DefaultContext ).Count (new (Webhook ))
60- stats .Counter .Milestone , _ = db .GetEngine (db .DefaultContext ).Count (new (Milestone ))
61- stats .Counter .Label , _ = db .GetEngine (db .DefaultContext ).Count (new (Label ))
62- stats .Counter .HookTask , _ = db .GetEngine (db .DefaultContext ).Count (new (HookTask ))
63- stats .Counter .Team , _ = db .GetEngine (db .DefaultContext ).Count (new (Team ))
64- stats .Counter .Attachment , _ = db .GetEngine (db .DefaultContext ).Count (new (Attachment ))
61+ stats .Counter .Webhook , _ = e .Count (new (Webhook ))
62+ stats .Counter .Milestone , _ = e .Count (new (Milestone ))
63+ stats .Counter .Label , _ = e .Count (new (Label ))
64+ stats .Counter .HookTask , _ = e .Count (new (HookTask ))
65+ stats .Counter .Team , _ = e .Count (new (Team ))
66+ stats .Counter .Attachment , _ = e .Count (new (Attachment ))
67+ stats .Counter .Project , _ = e .Count (new (Project ))
68+ stats .Counter .ProjectBoard , _ = e .Count (new (ProjectBoard ))
6569 return
6670}
0 commit comments