-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Rename order updater methods to better reflect behaviour #6368
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
Rename order updater methods to better reflect behaviour #6368
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6368 +/- ##
=======================================
Coverage 89.44% 89.45%
=======================================
Files 972 973 +1
Lines 20297 20314 +17
=======================================
+ Hits 18155 18172 +17
Misses 2142 2142 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ef0091f to
c2a8cbf
Compare
c2a8cbf to
ce41518
Compare
ce41518 to
6380632
Compare
jarednorman
left a comment
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 all looks good to me, but I'd love some reviews from people outside Super Good.
tvdeyen
left a comment
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.
Thanks. The last commit message has a typo. Other than that, great work.
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.
the git commit message has a typo
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.
Good catch, fixed the typo!
6380632 to
bc1b2b8
Compare
Update implies that we are persisting the change in Rails, which this method does not do. Co-authored-by: Adam Mueller <[email protected]> Co-authored-by: Senem Soy <[email protected]> Co-authored-by: Andrew Stewart <[email protected]> Co-authored-by: Kendra Riga <[email protected]> Co-authored-by: Sofia Besenski <[email protected]> Co-authored-by: benjamin wil <[email protected]>
Update implies that we are persisting the change in Rails, which this method does not do. Co-authored-by: Adam Mueller <[email protected]> Co-authored-by: Andrew Stewart <[email protected]> Co-authored-by: benjamin wil <[email protected]> Co-authored-by: Senem Soy <[email protected]> Co-authored-by: Sofia Besenski <[email protected]> Co-authored-by: Kendra Riga <[email protected]>
These methods don't persist so it's more accurate to say that they recalculate the total instead of saying that they update it. Co-Authored-By: Kendra Riga <[email protected]> Co-Authored-By: Sofia Besenski <[email protected]> Co-Authored-By: Chris Todorov <[email protected]>
bc1b2b8 to
289e596
Compare
mamhoff
left a comment
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'm a little bit confused by the last commit. So we rename the update_* methods to recalculate_*, because they don't persist - great. But then we rename recalculate_ methods to update_*, because they also don't persist? I don't know.
The other caveat I have here is that we have no protection for people who have subclassed and overridden the renamed methods. This can be done by combining the self.inherited and self.method_added hooks as I've done here: https://github.com/solidusio/solidus/blob/main/promotions/app/models/solidus_promotions/condition.rb#L104-L133. I'm not making this a condition for merging though, just a suggestion that you can go with or not.
😂 Good callout @mamhoff, I think that's a typo in the commit message. The This naming change is meant to help with the intention behind the methods provided by the order updater class. We have no control what anyone outside of this codebase does in their overrides, so I don't know that we need to take that into consideration, but happy to hear your thoughts if you think these methods are often overridden in apps. There is also a minor inconsistency here worth calling out, with the top level API of this class - |
The `recalculate_adjustments` method rebuilds the adjustments on the order, so it's more accurate to say that it updates instead of saying that it recalculates. Co-Authored-By: Kendra Riga <[email protected]> Co-Authored-By: Sofia Besenski <[email protected]> Co-Authored-By: Chris Todorov <[email protected]>
289e596 to
a859efc
Compare
Summary
In preparation for more changes to the order updater in #5872, we should rename the existing methods to better reflect what they actually do. We want
update_to encapsulate behaviour that persists, andrecalculate_Even though some of these are private methods, we are aware of a non-trivial amount of applications that override the methods of this core class, so we want to deprecate this renames before fully removing the alias'
OrderUpdater#update_shipment_state->OrderUpdater#recalculate_shipment_stateOrderUpdater#update_payment_state->OrderUpdater#recalculate_payment_stateOrderUpdater#update_payment_total->OrderUpdater#recalculate_payment_totalOrderUpdater#update_order_total->OrderUpdater#recalculate_order_totalOrderUpdater#update_shipment_total->OrderUpdater#recalculate_shipment_totalOrderUpdater#update_item_total->OrderUpdater#recalculate_item_totalOrderUpdater#update_item_totals->OrderUpdater#recalculate_item_totalsOrderUpdater#update_item_count->OrderUpdater#recalculate_item_countOrderUpdater#recalculate_adjustments->OrderUpdater#update_adjustmentsChecklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: