diff --git a/src/cljc/elo/games.cljc b/src/cljc/elo/games.cljc index a03af0c..93c4a16 100644 --- a/src/cljc/elo/games.cljc +++ b/src/cljc/elo/games.cljc @@ -112,26 +112,32 @@ (: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] + (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..d4547cc 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,9 @@ (rf/reg-sub ::rankings-history-vega :<- [::rankings-history] + :<- [::game-config] - (fn [history] + (fn [[history game-config]] (let [kw->keyname {:player "Player" :ranking "Ranking" :game-idx "Game #"