From 48c533cb78576396f8ce57cb9f2cb4fd32f51e81 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Fri, 22 Mar 2024 21:42:27 -0400 Subject: [PATCH] Fix higher score being overwritten by worse daily runs --- db/daily.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/daily.go b/db/daily.go index 237d81c..c4d0f5e 100644 --- a/db/daily.go +++ b/db/daily.go @@ -14,7 +14,7 @@ func TryAddDailyRun(seed string) error { } func AddOrUpdateAccountDailyRun(uuid []byte, score int, wave int) error { - _, err := handle.Exec("INSERT INTO accountDailyRuns (uuid, date, score, wave, timestamp) VALUES (?, UTC_DATE(), ?, ?, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE score = ?, wave = GREATEST(wave, ?), timestamp = IF(score < ?, UTC_TIMESTAMP(), timestamp)", uuid, score, wave, score, wave, score) + _, err := handle.Exec("INSERT INTO accountDailyRuns (uuid, date, score, wave, timestamp) VALUES (?, UTC_DATE(), ?, ?, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE score = GREATEST(score, ?), wave = GREATEST(wave, ?), timestamp = IF(score < ?, UTC_TIMESTAMP(), timestamp)", uuid, score, wave, score, wave, score) if err != nil { return err }