Loading cache_data.go +2 −3 Original line number Diff line number Diff line package main import ( "fmt" "strconv" "git.zxq.co/ripple/ocl" Loading Loading @@ -38,7 +37,7 @@ func opCacheData() { // analyse every result row of fetchQuery for rows.Next() { if count%1000 == 0 { fmt.Println("> CacheData:", count) verboseln("> CacheData:", count) } var ( uid int Loading Loading @@ -88,7 +87,7 @@ func opCacheData() { count = 0 for rows.Next() { if count%100 == 0 { fmt.Println("> CacheLevel:", count) verboseln("> CacheLevel:", count) } var ( id int Loading calculate_accuracy.go +1 −2 Original line number Diff line number Diff line package main import ( "fmt" "math" "github.com/fatih/color" Loading @@ -17,7 +16,7 @@ func opCalculateAccuracy() { count := 0 for rows.Next() { if count%1000 == 0 { fmt.Println("> CalculateAccuracy:", count) verboseln("> CalculateAccuracy:", count) } var ( id int Loading calculate_pp.go +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ func opCalculatePP() { for rows.Next() { if count%1000 == 0 { fmt.Println("> CalculatePP:", count) verboseln("> CalculatePP:", count) } var ( userid int Loading cron.go +24 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package main import ( "database/sql" "flag" "fmt" "net/http" "sync" Loading Loading @@ -32,7 +33,6 @@ type config struct { RemoveDonorOnExpired bool FixMultipleCompletedScores bool `description:"Set completed=2 if multiple completed=3 scores for same beatmap and user are present."` LogQueries bool `description:"You don't wanna do this in prod."` Workers int `description:"The number of goroutines which should execute queries. Increasing it may make cron faster, depending on your system."` } Loading @@ -43,6 +43,16 @@ var c = config{ } var wg sync.WaitGroup var chanWg sync.WaitGroup var v bool var vv bool func init() { flag.BoolVar(&v, "v", false, "verbose") flag.BoolVar(&vv, "vv", false, "very verbose (LogQueries)") flag.Parse() v = vv || v } func main() { // Set up the configuration. Loading Loading @@ -208,7 +218,7 @@ func queryError(err error, query string, params ...interface{}) { } func logquery(q string, params []interface{}) { if c.LogQueries { if vv { // porcodio go se sei odioso a := []interface{}{ "=>", Loading @@ -219,3 +229,14 @@ func logquery(q string, params []interface{}) { fmt.Println(a...) } } func verbosef(format string, args ...interface{}) { if v { fmt.Printf(format, args...) } } func verboseln(args ...interface{}) { if v { fmt.Println(args...) } } fix_multiple_completed_scores.go +3 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ func opFixMultipleCompletedScores() { fixed := []int{} for i := 0; i < len(scores); i++ { if i%1000 == 0 { fmt.Println("> FixMultipleCompletedScores:", i) verboseln("> FixMultipleCompletedScores:", i) } if contains(fixed, scores[i].id) { continue Loading @@ -40,9 +40,9 @@ func opFixMultipleCompletedScores() { if contains(fixed, scores[j].id) { continue } if (scores[j].id != scores[i].id && scores[j].beatmapMD5 == scores[i].beatmapMD5 && scores[j].userid == scores[i].userid && scores[j].playMode == scores[i].playMode) { if scores[j].id != scores[i].id && scores[j].beatmapMD5 == scores[i].beatmapMD5 && scores[j].userid == scores[i].userid && scores[j].playMode == scores[i].playMode { fmt.Printf("> FixMultipleCompletedScores: Found duplicated completed score (%d/%d)\n", scores[i].id, scores[j].id) if (scores[j].score > scores[i].score) { if scores[j].score > scores[i].score { op("UPDATE scores SET completed = 2 WHERE id = ?", scores[i].id) } else { op("UPDATE scores SET completed = 2 WHERE id = ?", scores[j].id) Loading Loading
cache_data.go +2 −3 Original line number Diff line number Diff line package main import ( "fmt" "strconv" "git.zxq.co/ripple/ocl" Loading Loading @@ -38,7 +37,7 @@ func opCacheData() { // analyse every result row of fetchQuery for rows.Next() { if count%1000 == 0 { fmt.Println("> CacheData:", count) verboseln("> CacheData:", count) } var ( uid int Loading Loading @@ -88,7 +87,7 @@ func opCacheData() { count = 0 for rows.Next() { if count%100 == 0 { fmt.Println("> CacheLevel:", count) verboseln("> CacheLevel:", count) } var ( id int Loading
calculate_accuracy.go +1 −2 Original line number Diff line number Diff line package main import ( "fmt" "math" "github.com/fatih/color" Loading @@ -17,7 +16,7 @@ func opCalculateAccuracy() { count := 0 for rows.Next() { if count%1000 == 0 { fmt.Println("> CalculateAccuracy:", count) verboseln("> CalculateAccuracy:", count) } var ( id int Loading
calculate_pp.go +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ func opCalculatePP() { for rows.Next() { if count%1000 == 0 { fmt.Println("> CalculatePP:", count) verboseln("> CalculatePP:", count) } var ( userid int Loading
cron.go +24 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package main import ( "database/sql" "flag" "fmt" "net/http" "sync" Loading Loading @@ -32,7 +33,6 @@ type config struct { RemoveDonorOnExpired bool FixMultipleCompletedScores bool `description:"Set completed=2 if multiple completed=3 scores for same beatmap and user are present."` LogQueries bool `description:"You don't wanna do this in prod."` Workers int `description:"The number of goroutines which should execute queries. Increasing it may make cron faster, depending on your system."` } Loading @@ -43,6 +43,16 @@ var c = config{ } var wg sync.WaitGroup var chanWg sync.WaitGroup var v bool var vv bool func init() { flag.BoolVar(&v, "v", false, "verbose") flag.BoolVar(&vv, "vv", false, "very verbose (LogQueries)") flag.Parse() v = vv || v } func main() { // Set up the configuration. Loading Loading @@ -208,7 +218,7 @@ func queryError(err error, query string, params ...interface{}) { } func logquery(q string, params []interface{}) { if c.LogQueries { if vv { // porcodio go se sei odioso a := []interface{}{ "=>", Loading @@ -219,3 +229,14 @@ func logquery(q string, params []interface{}) { fmt.Println(a...) } } func verbosef(format string, args ...interface{}) { if v { fmt.Printf(format, args...) } } func verboseln(args ...interface{}) { if v { fmt.Println(args...) } }
fix_multiple_completed_scores.go +3 −3 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ func opFixMultipleCompletedScores() { fixed := []int{} for i := 0; i < len(scores); i++ { if i%1000 == 0 { fmt.Println("> FixMultipleCompletedScores:", i) verboseln("> FixMultipleCompletedScores:", i) } if contains(fixed, scores[i].id) { continue Loading @@ -40,9 +40,9 @@ func opFixMultipleCompletedScores() { if contains(fixed, scores[j].id) { continue } if (scores[j].id != scores[i].id && scores[j].beatmapMD5 == scores[i].beatmapMD5 && scores[j].userid == scores[i].userid && scores[j].playMode == scores[i].playMode) { if scores[j].id != scores[i].id && scores[j].beatmapMD5 == scores[i].beatmapMD5 && scores[j].userid == scores[i].userid && scores[j].playMode == scores[i].playMode { fmt.Printf("> FixMultipleCompletedScores: Found duplicated completed score (%d/%d)\n", scores[i].id, scores[j].id) if (scores[j].score > scores[i].score) { if scores[j].score > scores[i].score { op("UPDATE scores SET completed = 2 WHERE id = ?", scores[i].id) } else { op("UPDATE scores SET completed = 2 WHERE id = ?", scores[j].id) Loading