From 0829e56ed54a120d38eac23b4983a2ebd8927e87 Mon Sep 17 00:00:00 2001 From: Andrea Crotti Date: Thu, 24 Jan 2019 19:15:55 +0000 Subject: [PATCH 1/3] push game-config through the history generation --- src/cljc/elo/games.cljc | 40 ++++++++++++++---------- src/cljs/elo/league_detail/handlers.cljs | 9 ++++-- src/cljs/elo/league_detail/views.cljs | 3 +- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/cljc/elo/games.cljc b/src/cljc/elo/games.cljc index a03af0c..de41935 100644 --- a/src/cljc/elo/games.cljc +++ b/src/cljc/elo/games.cljc @@ -80,6 +80,7 @@ (get-rankings games players shared/default-game-config)) ([games players config] + (println "config =" config) (let [norm-games (map elo/normalize-game games) rankings (elo/compute-rankings norm-games (map :id players) @@ -112,26 +113,33 @@ (:p2_points game))) (defn rankings-at-idx* - [players idx all-games] - (let [current-game (nth all-games idx) - name-mapping (player->names players) - common-map - {:game-idx idx - :time (:played_at current-game) - :result (game-result current-game name-mapping)} + ([players idx all-games] + (rankings-at-idx* players idx all-games shared/default-game-config)) - rankings (get-rankings (take (inc idx) all-games) players)] + ([players idx all-games game-config] + (let [current-game (nth all-games idx) + name-mapping (player->names players) + common-map + {:game-idx idx + :time (:played_at current-game) + :result (game-result current-game name-mapping)} - (map #(merge % common-map) - (for [r (filter #(plays? current-game (:id %)) rankings)] - {:ranking (:ranking r) - :player (name-mapping (:id r))})))) + rankings (get-rankings (take idx all-games) players)] + + (map #(merge % common-map) + (for [r (filter #(plays? current-game (:id %)) rankings)] + {:ranking (:ranking r) + :player (name-mapping (:id r))}))))) (defn rankings-history - [players games] - (flatten - (for [idx (range (count games))] - (rankings-at-idx* players idx games)))) + ([players games] + (rankings-history players games shared/default-game-config)) + + ([players games game-config] + (println "rankings history:" "config = " game-config) + (flatten + (for [idx (range (count games))] + (rankings-at-idx* players idx games game-config))))) (defn longest-winning-subseq [s] diff --git a/src/cljs/elo/league_detail/handlers.cljs b/src/cljs/elo/league_detail/handlers.cljs index 1ce3273..89089cf 100644 --- a/src/cljs/elo/league_detail/handlers.cljs +++ b/src/cljs/elo/league_detail/handlers.cljs @@ -89,9 +89,10 @@ :<- [::visible-players] :<- [::games-live-players] :<- [::up-to-games] + :<- [::game-config] - (fn [[players visible-players games up-to]] - (rankings/rankings-history players visible-players games up-to))) + (fn [[players visible-players games up-to game-config]] + (rankings/rankings-history players visible-players games up-to game-config))) (rf/reg-sub ::last-game-played-by :<- [::games-live-players] @@ -310,8 +311,10 @@ (rf/reg-sub ::rankings-history-vega :<- [::rankings-history] + :<- [::game-config] - (fn [history] + (fn [[history game-config]] + (js/console.log "history changed now") (let [kw->keyname {:player "Player" :ranking "Ranking" :game-idx "Game #" diff --git a/src/cljs/elo/league_detail/views.cljs b/src/cljs/elo/league_detail/views.cljs index dca87b3..43e4527 100644 --- a/src/cljs/elo/league_detail/views.cljs +++ b/src/cljs/elo/league_detail/views.cljs @@ -320,6 +320,7 @@ (let [history (rf/subscribe [::handlers/rankings-history-vega]) rankings-domain (rf/subscribe [::handlers/rankings-domain])] (fn [] + (js/console.log "Recomputing the history and the rankings domain") [vega/vega-inner @history @rankings-domain]))) (defn- percent @@ -402,6 +403,6 @@ [stats-component ::stats-specs/best-percents]] [:div.section.vega__table [vega-outer]] - #_[:div.section.game__config [game-config]] + [:div.section.game__config [game-config]] [:div.section.rankings__table [rankings-table]] [:div.section.games__table [games-table]]])) From d20bdce361fbc42b561b8a917a2f8e5572c7bbae Mon Sep 17 00:00:00 2001 From: Andrea Crotti Date: Sun, 3 Feb 2019 11:26:36 +0000 Subject: [PATCH 2/3] disable config for now --- src/cljs/elo/league_detail/views.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cljs/elo/league_detail/views.cljs b/src/cljs/elo/league_detail/views.cljs index 43e4527..f467b80 100644 --- a/src/cljs/elo/league_detail/views.cljs +++ b/src/cljs/elo/league_detail/views.cljs @@ -403,6 +403,6 @@ [stats-component ::stats-specs/best-percents]] [:div.section.vega__table [vega-outer]] - [:div.section.game__config [game-config]] + #_[:div.section.game__config [game-config]] [:div.section.rankings__table [rankings-table]] [:div.section.games__table [games-table]]])) From 1a3939ce5ce9131a9943b7078873aed5f4b18c80 Mon Sep 17 00:00:00 2001 From: Andrea Crotti Date: Sun, 3 Feb 2019 16:37:07 +0000 Subject: [PATCH 3/3] remove prints --- src/cljc/elo/games.cljc | 2 -- src/cljs/elo/league_detail/handlers.cljs | 1 - src/cljs/elo/league_detail/views.cljs | 1 - 3 files changed, 4 deletions(-) diff --git a/src/cljc/elo/games.cljc b/src/cljc/elo/games.cljc index de41935..93c4a16 100644 --- a/src/cljc/elo/games.cljc +++ b/src/cljc/elo/games.cljc @@ -80,7 +80,6 @@ (get-rankings games players shared/default-game-config)) ([games players config] - (println "config =" config) (let [norm-games (map elo/normalize-game games) rankings (elo/compute-rankings norm-games (map :id players) @@ -136,7 +135,6 @@ (rankings-history players games shared/default-game-config)) ([players games game-config] - (println "rankings history:" "config = " game-config) (flatten (for [idx (range (count games))] (rankings-at-idx* players idx games game-config))))) diff --git a/src/cljs/elo/league_detail/handlers.cljs b/src/cljs/elo/league_detail/handlers.cljs index 89089cf..d4547cc 100644 --- a/src/cljs/elo/league_detail/handlers.cljs +++ b/src/cljs/elo/league_detail/handlers.cljs @@ -314,7 +314,6 @@ :<- [::game-config] (fn [[history game-config]] - (js/console.log "history changed now") (let [kw->keyname {:player "Player" :ranking "Ranking" :game-idx "Game #" diff --git a/src/cljs/elo/league_detail/views.cljs b/src/cljs/elo/league_detail/views.cljs index f467b80..dca87b3 100644 --- a/src/cljs/elo/league_detail/views.cljs +++ b/src/cljs/elo/league_detail/views.cljs @@ -320,7 +320,6 @@ (let [history (rf/subscribe [::handlers/rankings-history-vega]) rankings-domain (rf/subscribe [::handlers/rankings-domain])] (fn [] - (js/console.log "Recomputing the history and the rankings domain") [vega/vega-inner @history @rankings-domain]))) (defn- percent