Nil check battle and classic session count

pull/4/head
Matthew Olker 8 months ago
parent a4014feea8
commit 6a0a130b1d

3
.gitignore vendored

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

@ -12,7 +12,7 @@ func FetchPlayerCount() (int, error) {
func FetchBattleCount() (int, error) {
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 {
return 0, err
}
@ -22,7 +22,7 @@ func FetchBattleCount() (int, error) {
func FetchClassicSessionCount() (int, error) {
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 {
return 0, err
}

Loading…
Cancel
Save