From b90e284a26d8fdfbfef353ad4e3568c1fe28e50a Mon Sep 17 00:00:00 2001 From: John Warwick Date: Thu, 10 Jun 2021 11:27:50 -0400 Subject: [PATCH 1/2] Decapitate zombie games --- src/clj/web/stats.clj | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/clj/web/stats.clj b/src/clj/web/stats.clj index 1804b910de..ba80485014 100644 --- a/src/clj/web/stats.clj +++ b/src/clj/web/stats.clj @@ -44,7 +44,7 @@ (defn build-stats-kw "Take a stats prefix and add a side to it" [prefix side] - (keyword (apply str prefix (lower-case side)))) + (keyword (apply str prefix (lower-case (or side "Corp"))))) (defn inc-deck-stats "Update deck stats for a given counter" @@ -112,9 +112,11 @@ (let [start-players (get-in @all-games [gameid :original-players]) end-players (get-in @all-games [gameid :ending-players])] (doseq [p start-players] - (inc-game-stats db (get-in p [:user :_id]) (game-record-start p))) + (when (:side p) + (inc-game-stats db (get-in p [:user :_id]) (game-record-start p)))) (doseq [p end-players] - (inc-game-stats db (get-in p [:user :_id]) (game-record-end all-games gameid p))))) + (when (:side p) + (inc-game-stats db (get-in p [:user :_id]) (game-record-end all-games gameid p)))))) (defn push-stats-update "Gather updated deck and user stats and send via web socket to clients" From 8555fc2c84196a53a87f329b7b0f961af02d5d27 Mon Sep 17 00:00:00 2001 From: John Warwick Date: Thu, 10 Jun 2021 14:21:48 -0400 Subject: [PATCH 2/2] Print gameid if null player side --- src/clj/web/stats.clj | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/clj/web/stats.clj b/src/clj/web/stats.clj index ba80485014..2a87b35783 100644 --- a/src/clj/web/stats.clj +++ b/src/clj/web/stats.clj @@ -112,11 +112,13 @@ (let [start-players (get-in @all-games [gameid :original-players]) end-players (get-in @all-games [gameid :ending-players])] (doseq [p start-players] - (when (:side p) - (inc-game-stats db (get-in p [:user :_id]) (game-record-start p)))) + (if (:side p) + (inc-game-stats db (get-in p [:user :_id]) (game-record-start p)) + (println "NULL start player side in stats for gameid" gameid))) (doseq [p end-players] - (when (:side p) - (inc-game-stats db (get-in p [:user :_id]) (game-record-end all-games gameid p)))))) + (if (:side p) + (inc-game-stats db (get-in p [:user :_id]) (game-record-end all-games gameid p)) + (println "NULL end player side in stats for gameid" gameid))))) (defn push-stats-update "Gather updated deck and user stats and send via web socket to clients"