forked from osuripple/ripple-cron-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverwise_stats.go
More file actions
37 lines (31 loc) · 812 Bytes
/
serverwise_stats.go
File metadata and controls
37 lines (31 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"github.com/fatih/color"
)
type statType struct {
query string
redisKey string
value int
}
func opServerwiseStats() {
defer wg.Done()
stats := []statType {
statType {
query: "SELECT COUNT(id) AS c FROM scores LIMIT 1",
redisKey: "ripple:total_submitted_scores",
},
statType {
query: "SELECT SUM(playcount_std) + SUM(playcount_taiko) + SUM(playcount_ctb) + SUM(playcount_mania) FROM users_stats WHERE 1",
redisKey: "ripple:total_plays",
},
statType {
query: "SELECT SUM(pp_std) + SUM(pp_taiko) + SUM(pp_ctb) + SUM(pp_mania) AS s FROM users_stats WHERE 1 LIMIT 1",
redisKey: "ripple:total_pp",
},
}
for _, v := range stats {
db.QueryRow(v.query).Scan(&v.value)
r.Set(v.redisKey, v.value, 0)
}
color.Green("> Server-wise Stats: done!")
}