@@ -18,28 +18,30 @@ type Statistic struct {
18
18
Comment , Oauth , Follow ,
19
19
Mirror , Release , LoginSource , Webhook ,
20
20
Milestone , Label , HookTask ,
21
- Team , UpdateTask , Attachment int64
21
+ Team , UpdateTask , Project ,
22
+ ProjectBoard , Attachment int64
22
23
}
23
24
}
24
25
25
26
// GetStatistic returns the database statistics
26
27
func GetStatistic () (stats Statistic ) {
28
+ e := db .GetEngine (db .DefaultContext )
27
29
stats .Counter .User = CountUsers ()
28
30
stats .Counter .Org = CountOrganizations ()
29
- stats .Counter .PublicKey , _ = db . GetEngine ( db . DefaultContext ) .Count (new (PublicKey ))
31
+ stats .Counter .PublicKey , _ = e .Count (new (PublicKey ))
30
32
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 ))
35
37
36
38
type IssueCount struct {
37
39
Count int64
38
40
IsClosed bool
39
41
}
40
42
issueCounts := []IssueCount {}
41
43
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 )
43
45
for _ , c := range issueCounts {
44
46
if c .IsClosed {
45
47
stats .Counter .IssueClosed = c .Count
@@ -50,17 +52,19 @@ func GetStatistic() (stats Statistic) {
50
52
51
53
stats .Counter .Issue = stats .Counter .IssueClosed + stats .Counter .IssueOpen
52
54
53
- stats .Counter .Comment , _ = db . GetEngine ( db . DefaultContext ) .Count (new (Comment ))
55
+ stats .Counter .Comment , _ = e .Count (new (Comment ))
54
56
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 ))
58
60
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 ))
65
69
return
66
70
}
0 commit comments