Changes for cache_data.go: 178 added lines, 0 removed lines.
Original line number
Diff line number
Diff line
packagemain
import(
"fmt"
"math"
"strconv"
)
typesstruct{
rankedScoreint64
totalHitsint64
levelint
}
funcopCacheData(){
// get data
constfetchQuery=`SELECT users.id as user_id, users.username, scores.play_mode, scores.score, scores.completed, scores.300_count, scores.100_count, scores.50_count FROM scores LEFT JOIN users ON users.username=scores.username WHERE users.allowed = '1'`
Changes for cron.go: 156 added lines, 0 removed lines.
Original line number
Diff line number
Diff line
packagemain
import(
"database/sql"
"fmt"
"sync"
"github.com/fatih/color"
_"github.com/go-sql-driver/mysql"
"github.com/thehowl/conf"
)
typeconfigstruct{
DSNstring
RippleDirstring`description:"The ripple folder (e.g. /var/www/ripple, NOT /var/www/ripple/osu.ppy.sh). Write the directory relatively to where the ripple-cron-go executable is placed."`
CalculateAccuracybool
CacheRankedScorebool
CacheTotalHitsbool
CacheLevelbool
DeleteOldPasswordResetsbool
CleanReplaysbool
DeleteReplayCachebool
BuildLeaderboardsbool
LogQueriesbool`description:"You don't wanna do this in prod."`
}
vardb*sql.DB
varcconfig
varwgsync.WaitGroup
varchanWgsync.WaitGroup
funcmain(){
// Set up the configuration.
err:=conf.Load(&c,"cron.conf")
switch{
caseerr==conf.ErrNoFile:
color.Yellow("No cron.conf was found. Creating it...")
err:=conf.Export(&c,"cron.conf")
iferr!=nil{
color.Red("Couldn't create cron.conf: %v.",err)
}else{
color.Green("cron.conf has been created!")
}
return
caseerr!=nil:
color.Red("cron.conf couldn't be loaded: %v.",err)
return
}
fmt.Println(`
___ _ __ ___ _ __
/ __| '__/ _ \| '_ \
| (__| | | (_) | | | |
\___|_| \___/|_| |_|
`)
color.Green(" (not so) proudly brought to you by")
color.Green(" The Ripple Team™")
fmt.Println()
fmt.Print("Starting MySQL connection...")
// start database connection
db,err=sql.Open("mysql",c.DSN)
iferr!=nil{
color.Red(" couldn't start MySQL connection: %v",err)