Repository navigation
feat(shopping-list): --from / --to for some days of a menu - #612
Merged
Merged
Conversation
LeMyst
marked this pull request as ready for review
October 4, 2026 21:19
`cook shopping-list Plans/October.menu --from 2026-10-07 --to 2026-10-13` shops for that week only: the sections dated in the range (a YYYY-MM-DD in the name, as meal plans and the editor's Day button write them), with the recipes they reference expanded as usual and the ingredients written into them. Both ends are included and either may be left out; `today` is accepted. - Undated sections are not days, so a range leaves them out. - A recipe, or a menu with no dated section, is taken whole; for a menu a warning says so. A menu with no day in range adds nothing, with a warning. - A reversed range or a malformed date is refused. - Optional ingredients on the days kept follow --include-optional as everywhere else. In core, `ScaledRecipe` gains `days: Option<DayRange>` (and `on_days`), so a request can narrow one menu and not another. `add_ingredients` takes the ingredients the chosen sections use and skips the rest, counting only the in-range members of an ingredient group; the references among them are expanded unchanged. `section_date` moves to core with the planner's rule (the first `YYYY-MM-DD` in a section name, `Wednesday (2026-10-07)` or `2026-10-07 Dinner`), and `web::plan::section_date` builds on it, so the calendar and the shopping list agree on what a day is. The server's two struct literals use the constructor instead. Part of cooklang#385. Co-Authored-By: Claude Opus 5.5 <[email protected]>
LeMyst
force-pushed
the
feat/shopping-list-dates
branch
from
October 4, 2026 21:39
0bb1133 to
0b5e815
Compare
This was referenced Oct 10, 2026
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.
Part of #385: the
cook shopping-listday filter listed as still open in the summary. Independent of the other PRs. Rebased onto main 0734d32 (after #592, #596, #610).A menu's days are its sections whose name holds a
YYYY-MM-DDdate (== Wednesday (2026-10-07) ==,= 2026-10-07 Dinner), as meal plans (#596) and the editor's Day button write them. With--from,--toor both, only the days in range go on the list: the recipes they reference, expanded as usual, and the ingredients written into them (@almonds{50%g}). Both ends are included; either may be left out;todayis accepted.Behaviour
== Leftovers ==,== Day 1 ==) are not days, so a range leaves them out.None of this menu's days is in the range asked for (from 2027-01-01), so nothing from it is on the list.--from 2026-10-07 --to 2026-10-01) or a malformed date is an error.Week.menu:2) applies to the days kept.--include-optionalas everywhere else.Implementation
crates/core/src/shopping_list/days.rs):ScaledRecipegainsdays: Option<DayRange>plusScaledRecipe::on_days, so one request can narrow a menu and keep a recipe whole.ScaledRecipe::new/scaledset it toNone; the server's two struct literals now usescaled(no behaviour change there).section_datelives in core and follows the planner's rule from feat(ui): meal plans laid out as a calendar #596: the firstYYYY-MM-DDanywhere in the section name, not inside a longer number.web::plan::section_datenow builds on it (it returns the rest of the name too, for the meal), so the calendar and the shopping list cannot disagree on what a day is.add_ingredients(the function feat(shopping-list): leave optional ingredients out unless --include-optional #592 added): ingredients outside them are neither listed nor returned for expansion, so the listing, optional and reference rules stay in one place. An ingredient group (&references) counts only its in-range members (days::kept_quantity). Today's parser doesn't enable&, but the code doesn't assume that.@./stew{}on a different day is its own ingredient, so the same recipe on two kept days is expanded twice, exactly as without a range.Tests
section_datecases (both heading styles); a plan headed= 2026-10-06 Dinner; optional ingredients on a kept day, with and without--include-optional; one day kept; open-ended ranges; undated sections dropped; the menu's scale applied to the kept days; a recipe taken whole without a warning; an undated menu taken whole with a warning; no day in range.tests/shopping_list_test.rs, config isolated):--from/--to,--toalone, the no-day warning, a bad date and a reversed range refused,--from today.cargo fmt,cargo clippy --all-targetsclean (--no-default-featuresshows only the warnings already on main),cargo test: 1085 passed, 0 failed.Docs:
docs/shopping-list.mdoptions table, examples and a "Some days of a menu" section.Possible follow-up: #611 filters a menu's days server-side for the web shopping list. Once both are in, it could build on
DayRangehere (it already sharessection_datethroughweb::plan).🤖 Generated with Claude Code
https://claude.ai/code/session_01RXA3hAKY9Q8hLCZGeokLPK