Add the Supply run API, item toggles and the Push to Calendar hook
GET /api/v1/shopping/{weekStart} reads the week's Supply run with its
week label, counts and groups by plan day; POST
/api/v1/shopping/{weekStart}/generate makes or remakes it through
shopping.Generate; PATCH /api/v1/shopping/items/{id} sets an item's
needed flag and answers with the list's new counts, 409 archived once
the list is in the Supply archive and 404 for an unknown item.
A successful Push to Calendar now makes the pushed week's Supply run.
Generation runs after the push is recorded and never fails or undoes
it: the 200 answer reports supply_run generated, archived or failed,
and a failure is logged as an error.
Maestro task d076480c-6c59-4c57-9023-6941badb4520.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -58,3 +58,26 @@ WHERE id = ?;
|
||||
-- name: DeleteShoppingItem :exec
|
||||
DELETE FROM shopping_items
|
||||
WHERE id = ?;
|
||||
|
||||
-- name: ListShoppingGroupDinners :many
|
||||
-- The groups of list list_id with their dinner's name, in list order.
|
||||
SELECT sqlc.embed(shopping_groups), dinners.name AS dinner_name
|
||||
FROM shopping_groups
|
||||
JOIN dinners ON dinners.id = shopping_groups.dinner_id
|
||||
WHERE shopping_groups.list_id = ?
|
||||
ORDER BY shopping_groups.position, shopping_groups.id;
|
||||
|
||||
-- name: GetShoppingItemList :one
|
||||
-- The Supply run holding item id. Returns sql.ErrNoRows when there is no
|
||||
-- such item.
|
||||
SELECT sqlc.embed(shopping_lists)
|
||||
FROM shopping_items
|
||||
JOIN shopping_groups ON shopping_groups.id = shopping_items.group_id
|
||||
JOIN shopping_lists ON shopping_lists.id = shopping_groups.list_id
|
||||
WHERE shopping_items.id = ?;
|
||||
|
||||
-- name: SetShoppingItemNeeded :exec
|
||||
-- Marks item id needed (1) or "have it" (0).
|
||||
UPDATE shopping_items
|
||||
SET needed = ?, updated_at = ?
|
||||
WHERE id = ?;
|
||||
|
||||
Reference in New Issue
Block a user