-
Notifications
You must be signed in to change notification settings - Fork 4
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 amounts calculation #1188
Conversation
…ve the concern whilst keeping the callback (first step)
9528b95
to
4fc0d77
Compare
4fc0d77
to
ee82f9f
Compare
15f9235
to
563f0da
Compare
563f0da
to
60799fe
Compare
19cfc6a
to
e18305d
Compare
a2fae19
to
30437f4
Compare
6893ca7
to
6a0173d
Compare
6a0173d
to
03ad732
Compare
c91024d
to
72dfac2
Compare
72dfac2
to
d60db59
Compare
app/controllers/pfmps_controller.rb
Outdated
@@ -22,7 +22,7 @@ def edit; end | |||
def create | |||
@pfmp = Pfmp.new(pfmp_params.merge(schooling: @schooling)) | |||
|
|||
if @pfmp.save | |||
if PfmpManager.new(@pfmp).update(pfmp_params) |
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.
La fonction 'create' et 'update' n'avaient pas la même condition initialement, mais maintenant elles vérifient toutes les 2 'PfmpManager.new(@PFMP).update(pfmp_params)', est-ce normal ?
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.
Oui normalement c'est équivalent parce que #update
et #save
retournent true quand les validations sont passées et false quand ca n'est pas le cas. Et ici on veut juste déclencher explicitement le recalcul.
726b420
to
d96b7c6
Compare
3a2e779
to
d826392
Compare
d826392
to
fafc857
Compare
Here be dragons 💀
Time to clean the way we calculate amounts, mere mortal
PfmpManager
) 🎯About the removal of after_save callback check
Why remove it? Because it sucks, amounts ceilings can be exceeded by spamming requests, rebalancing could happily trigger other rebalancing (the fact that it doesnt currently is pure fluke), highway to Callback Hell 👿 and also just to simplify the mental model around this unnecessarily complex process.
Replaced by what? A new method on the
PfmpManager
calledupdate
->PfmpManager.new(pfmp).update(day_count: X)
with no side effects other than the one we want which is rebalancing of other pfmps for that same mef.Retrocompatibility issues
What are the entry points of those callbacks? -> AFAIK:
Risks