Nil check battle and classic session count

fasthttp
Matthew Olker 2024-04-11 18:40:37 -04:00
parent a4014feea8
commit 6a0a130b1d
2 changed files with 4 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
pokerogue-server.exe # no extension on linux, .exe on windows
pokerogue-server*
userdata/* userdata/*
secret.key secret.key

View File

@ -12,7 +12,7 @@ func FetchPlayerCount() (int, error) {
func FetchBattleCount() (int, error) { func FetchBattleCount() (int, error) {
var battleCount int var battleCount int
err := handle.QueryRow("SELECT SUM(battles) FROM accountStats").Scan(&battleCount) err := handle.QueryRow("SELECT COALESCE(SUM(battles), 0) FROM accountStats").Scan(&battleCount)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -22,7 +22,7 @@ func FetchBattleCount() (int, error) {
func FetchClassicSessionCount() (int, error) { func FetchClassicSessionCount() (int, error) {
var classicSessionCount int var classicSessionCount int
err := handle.QueryRow("SELECT SUM(classicSessionsPlayed) FROM accountStats").Scan(&classicSessionCount) err := handle.QueryRow("SELECT COALESCE(SUM(classicSessionsPlayed), 0) FROM accountStats").Scan(&classicSessionCount)
if err != nil { if err != nil {
return 0, err return 0, err
} }