Skip to content
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

Merged
merged 8 commits into from
Apr 9, 2018

Conversation

seb231
Copy link
Contributor

@seb231 seb231 commented Apr 5, 2018

Allow modify transitions to apply to any kind of transition (joiner, mover or leaver)

(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")
Copy link
Contributor

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

(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
Copy link
Contributor

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

:setting-2))
(map #(vector (:setting-1 %)) to-maps)
(map #(vector (:setting-1 %) (:setting-2 %)) to-maps))]
(->> (mapcat (fn [year]
Copy link
Contributor

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?

Copy link
Contributor Author

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...

(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
Copy link
Contributor

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

Copy link
Contributor

@acron0 acron0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loads better

@seb231 seb231 merged commit edd683d into master Apr 9, 2018
@seb231 seb231 deleted the feature/apply-modify-transitions-to-any-transition branch April 9, 2018 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants