Created
August 12, 2018 23:41
-
-
Save chrismurrph/10c485f48e307936589fc5b1ddc93331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn identities-and-stages-hof | |
"The data doesn't have a player-year so we create it now. Also the games need to be | |
unique on their own, as they are stored in their own table. | |
Also the simplification of the lines for stage :improved is handled here. | |
The work for :nyt stage can be done always as :naive doesn't use those keys." | |
[desired-labels {:keys [stage]}] | |
(fn [idx {:keys [pname year games max] :as player-year}] | |
(let [player-year-id (make-player-year-id pname year) | |
label {:pname pname :year year} | |
make-simple (fn [games n] | |
(if (= :improved stage) | |
(->clj (simplify (clj->js games) n)) | |
games))] | |
(assoc player-year | |
:idx idx | |
:key idx | |
:ui/desired? (boolean (desired-labels label)) | |
:player-year-id player-year-id | |
:games (->> games | |
(mapv (fn [{:keys [x y]}] | |
(let [id (str player-year-id "_" x)] | |
{:id id :key id :x x :y y}))) | |
(#(make-simple % simplification))) | |
;; Easier to put these in than have a playerMap (not even used at :naive stage, but no harm having here) | |
:x 41 | |
:y max)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment