Commit 19f2e7ed authored by Howl's avatar Howl
Browse files

As usual output is starting to get big, default output must now be enabled with -v

parent b8b51feb
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
package main

import (
	"fmt"
	"strconv"

	"git.zxq.co/ripple/ocl"
@@ -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
@@ -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
+1 −2
Original line number Diff line number Diff line
package main

import (
	"fmt"
	"math"

	"github.com/fatih/color"
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ func opCalculatePP() {

	for rows.Next() {
		if count%1000 == 0 {
			fmt.Println("> CalculatePP:", count)
			verboseln("> CalculatePP:", count)
		}
		var (
			userid   int
+24 −3
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ package main

import (
	"database/sql"
	"flag"
	"fmt"
	"net/http"
	"sync"
@@ -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."`
}

@@ -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.
@@ -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{}{
			"=>",
@@ -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...)
	}
}
+3 −3
Original line number Diff line number Diff line
@@ -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
@@ -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