WIP: Introduce new middleware stock coordinator#6484
Conversation
We want to support additional keyword arguments to this class and a positional argument interferes with this. Co-authored-by: Jared Norman <jared@super.gd> Co-authored-by: Adam Mueller <adam@super.gd> Co-authored-by: Noah Silvera <noah@super.gd>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6484 +/- ##
==========================================
+ Coverage 89.68% 89.72% +0.03%
==========================================
Files 991 1000 +9
Lines 20832 20932 +100
==========================================
+ Hits 18683 18781 +98
- Misses 2149 2151 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Noah Silvera <noah@super.gd> Co-authored-by: Adam Mueller <adam@super.gd>
6b44d32 to
4a86af5
Compare
Co-authored-by: Noah Silvera <noah@super.gd> Co-authored-by: Adam Mueller <adam@super.gd>
This starts the pattern of delegating low level operations to middleware objects.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4a86af5 to
ca9ae0d
Compare
| context[:availability] = Spree::Stock::Availability.new( | ||
| variants: context[:desired].variants, | ||
| stock_locations: context[:stock_locations] | ||
| ) |
There was a problem hiding this comment.
This is definitely an example of how overusing this approach makes the code worse. This has seriously obfuscated the dependency chain of the availability and desired variants objects. If we have some dependent computed stuff like this, maybe we just make this methods on the context object or something? It's worth considering this further.
There was a problem hiding this comment.
Agreed! I didn't put too much thought into how things shook out entirely at this point in the draft. Will definitely revisit before opening for review.
WIP
This refactoring of the existing SimpleCoordinator leaves it in a state that retains the original functionality, and higher level shape, but encapsulates the lower level logic into middleware components.
Next steps will be to reconsider how the middleware components are encapsulated, setting up the middleware orchestration, and adding unit specs to prevent regressions.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: