feat(shopping): toggleCheck (idempotent)
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 2m20s

Idempotentes Setzen/Loeschen von shopping_cart_check-Eintraegen
ueber (name_key, unit_key). Check ueberlebt Recipe-Removals,
solange ein anderes Rezept weiterhin zur Zeile beitraegt —
verifiziert durch 3 neue Integrationstests (17 total).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-21 23:08:20 +02:00
parent 494b672e8d
commit 1889b0dea0
2 changed files with 62 additions and 6 deletions

View File

@@ -107,12 +107,22 @@ export function listShoppingList(
}
export function toggleCheck(
_db: Database.Database,
_nameKey: string,
_unitKey: string,
_checked: boolean
db: Database.Database,
nameKey: string,
unitKey: string,
checked: boolean
): void {
throw new Error('not implemented');
if (checked) {
db.prepare(
`INSERT INTO shopping_cart_check (name_key, unit_key)
VALUES (?, ?)
ON CONFLICT(name_key, unit_key) DO NOTHING`
).run(nameKey, unitKey);
} else {
db.prepare(
'DELETE FROM shopping_cart_check WHERE name_key = ? AND unit_key = ?'
).run(nameKey, unitKey);
}
}
export function clearCheckedItems(_db: Database.Database): void {