Repository navigation
Conversation
Naming a replacement only stored the foreign key. The swap runs inside sync_supermarket, which quantity changes and the midnight job call, so a manual item already on the list as "Tijdelijk uitverkocht" waited until the next sync. That sync could also read a basket cached while the product was still orderable, and a refused cart mutation was discarded. Saving the mapping now syncs immediately. Every sync drops the basket cache first, and a refused mutation is retried twice and then logged. Co-authored-by: Adrian Philipp <adri@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Naming a replacement did not order it. The swap only runs inside
sync_supermarket, andset_ingredient_replacementonly wrotereplacement_ingredient_id.What happened
Whey (#543, product 556846) and flatbread (#510) were put on the list with
set_ingredient_quantity, which syncs. Both were then given a replacement. That second call stored the mapping and stopped. The cart kept the sold-out primary,substituted_forstayed null, and the replacement never appeared.Manual quantities are included.
substitute/2runs on planned recipe quantities and on manual rows. Melk, pesto, and druiven did not swap because those primaries were still orderable. Flatbread later became orderable on its own, so there was nothing left to swap.The swap is not reserved for order placement or for recipe-planned items. It runs on every sync: a quantity change, planning or unplanning a recipe, and the Quantum job at 00:00 UTC. While a paid order is in flight, sync freezes and writes nothing.
"Tijdelijk uitverkocht" is a live basket verdict (
isOrderable: false). The stored product card staysIN_ASSORTMENT, sowarningis nil. Two things could still hide that signal after the mapping was saved:UpdateMyListBasketwas ignored. The pre-GraphQL client retried; the GraphQL client returned the error and sync threw it away.Fix
set_ingredient_replacementsyncs immediately after a successful save, including when the mapping is cleared. A product the basket already cannot deliver is swapped then.The sold-out primary stays in the cart. The replacement is added, and
substituted_foris set on that row once it is actually in the basket. A product that sells out later still waits for the next sync.Tests
mix check(format, credo --strict, compile --warnings-as-errors, 120 tests, sobelow).IN_ASSORTMENT, while the fixture basket says the same product cannot be delivered, is swapped bysync_supermarket/1(the midnight path).set_ingredient_replacementon that same setup orders the replacement andget_shopping_listreportssubstituted_for.