Repository navigation
fix(server): keep the ticks on aisle names when a recipe is removed - #655
Merged
Merged
Conversation
Removing a recipe from the shopping list drops the ticks of ingredients no longer on it. It compared the ticks with the names the recipes write (`eggs`), but the list is shown, and ticked, under the aisle file's common names (`egg`), so a ticked `egg` was dropped while another recipe still needed eggs. This has been so since 7700032 (cooklang#318); the aisles page's grouping makes such synonyms more common. The names to keep are now the recipes' own names and their common names, for the remove and for `POST /api/shopping_list/compact`. Reading the aisle file moves to `read_aisle_file`, shared with the list itself. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Closes #654
Problem
Removing a recipe from the shopping list unticked items still on the list. Since 7700032 (#318), the remove drops the ticks of ingredients no longer on the list, comparing them with the names the recipes write (
eggs). ButPOST /api/shopping_listshows the list, and the page ticks it, under the aisle file's common names (eggforegg | eggs). So a tickedeggwas dropped while another recipe still needed eggs.Seed repro: add Easy Pancakes and Mexican Style Burrito (both
@eggs), tickeggandbutter, remove the pancakes.checkedwent from["egg","butter"]to["butter"];butter, written the same in both recipes, kept its tick.Fix
aggregate_current_ingredient_namesreturns each name both as the recipes write it and as its common name in the aisle file. The common name is what the page ticks. The recipe name is kept too, so a tick made under it (before the aisles page grouped it, say) still counts. Compaction only ever drops ticks, so a longer list of names to keep can only keep more.This covers the remove and
POST /api/shopping_list/compact, the two callers. Reading the aisle file moves toread_aisle_file, shared with the list itself.Tests
Appended to
tests/shopping_list_remove_test.rs. The fixture gains two recipes usingeggsand aconfig/aisle.confwithegg | eggs.egg) survives the removeeggs) survivesmilk) is dropped,eggkeptcargo fmt --check,cargo clippy --all-targets: clean.cargo test --no-fail-fast: 1166 passed, 0 failed.curlagainst the fixed server:checkedstays["butter","egg"], andPOST /api/shopping_listanswers with both.No overlap with #648 (template only).
🤖 Generated with Claude Code