@@ -272,7 +272,8 @@ type Statistic struct {
272
272
Counter struct {
273
273
User , Org , PublicKey ,
274
274
Repo , Watch , Star , Action , Access ,
275
- IssueClosed , IssueOpen , Comment , Oauth , Follow ,
275
+ Issue , IssueClosed , IssueOpen ,
276
+ Comment , Oauth , Follow ,
276
277
Mirror , Release , LoginSource , Webhook ,
277
278
Milestone , Label , HookTask ,
278
279
Team , UpdateTask , Attachment int64
@@ -289,8 +290,24 @@ func GetStatistic() (stats Statistic) {
289
290
stats .Counter .Star , _ = x .Count (new (Star ))
290
291
stats .Counter .Action , _ = x .Count (new (Action ))
291
292
stats .Counter .Access , _ = x .Count (new (Access ))
292
- stats .Counter .IssueClosed , _ = x .Where ("is_closed=?" , true ).Count (new (Issue ))
293
- stats .Counter .IssueOpen , _ = x .Where ("is_closed=?" , false ).Count (new (Issue ))
293
+
294
+ type IssueCount struct {
295
+ Count int64
296
+ IsClosed bool
297
+ }
298
+ issueCounts := []IssueCount {}
299
+
300
+ _ = x .Select ("COUNT(*) AS count, is_closed" ).Table ("issue" ).GroupBy ("is_closed" ).Find (& issueCounts )
301
+ for _ , c := range issueCounts {
302
+ if c .IsClosed {
303
+ stats .Counter .IssueClosed = c .Count
304
+ } else {
305
+ stats .Counter .IssueOpen = c .Count
306
+ }
307
+ }
308
+
309
+ stats .Counter .Issue = stats .Counter .IssueClosed + stats .Counter .IssueOpen
310
+
294
311
stats .Counter .Comment , _ = x .Count (new (Comment ))
295
312
stats .Counter .Oauth = 0
296
313
stats .Counter .Follow , _ = x .Count (new (Follow ))
0 commit comments