-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor build-states-to-change #46
Refactor build-states-to-change #46
Conversation
src/clj/witan/send/send.clj
Outdated
(vector cy ay :NONSEND (states/state need setting))) | ||
(defn generate-transition-key [{:keys [transition-type cy ay need setting move-state]}] | ||
(when (not= move-state (states/state need setting)) | ||
(cond (= transition-type "joiners") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case
might be slightly nicer here
src/clj/witan/send/send.clj
Outdated
(generate-transition-key year age need (second setting)))) | ||
state-pairs)) valid-needs)) ages)) years))))) | ||
(defn build-states-to-change [input valid-needs valid-settings ages years transition-type] | ||
(let [to-maps (->> input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thread-last
not really required
src/clj/witan/send/send.clj
Outdated
:setting-2)) | ||
(map #(vector (:setting-1 %)) to-maps) | ||
(map #(vector (:setting-1 %) (:setting-2 %)) to-maps))] | ||
(->> (mapcat (fn [year] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is easy to follow but unlikely to be very performant. Perhaps there's another way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to take suggestions, I thought before that it didn't look very nice, but I do need to map over each of these seqs of things...
src/clj/witan/send/send.clj
Outdated
(vector (generate-transition-key (merge keys {:setting (first setting-to-change)})) | ||
(generate-transition-key (merge keys {:setting (second setting-to-change)})))))) | ||
settings-to-change)) valid-settings)) valid-needs)) ages)) years) | ||
vec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this vec is necesary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loads better
Allow modify transitions to apply to any kind of transition (joiner, mover or leaver)