You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
655 B
Go

package api
import (
"log"
"time"
"github.com/Flashfyre/pokerogue-server/db"
"github.com/go-co-op/gocron"
)
var (
statScheduler = gocron.NewScheduler(time.UTC)
playerCount int
battleCount int
classicSessionCount int
)
func ScheduleStatRefresh() {
statScheduler.Every(10).Second().Do(updateStats)
statScheduler.StartAsync()
}
func updateStats() {
var err error
playerCount, err = db.FetchPlayerCount()
if err != nil {
8 months ago
log.Print(err)
}
battleCount, err = db.FetchBattleCount()
if err != nil {
log.Print(err)
}
classicSessionCount, err = db.FetchClassicSessionCount()
if err != nil {
log.Print(err)
}
}