Files
MealQuest/migrations/queries/household_context.sql
T
dev_agent 6ff6443db7
CI / ci (push) Successful in 1m34s
Household context builder with token budget (#57)
Co-authored-by: dev_agent <dev_agent@cubecraftlabs.com>
2026-10-05 08:34:44 -04:00

20 lines
755 B
SQL

-- Reads for the AI household context block (internal/ai/harness).
-- name: ListRecentDeclinedNames :many
-- The names of the most recently declined suggestions, newest first.
SELECT dinners.name
FROM suggestions
JOIN dinners ON dinners.id = suggestions.dinner_id
WHERE suggestions.status = 'declined'
ORDER BY suggestions.decided_at DESC, suggestions.id DESC
LIMIT ?;
-- name: ListPlannedDinners :many
-- The planned dinners dated from from_date up to but not including
-- to_date, oldest first. Days with no dinner are left out.
SELECT plan_days.date, dinners.name
FROM plan_days
JOIN dinners ON dinners.id = plan_days.dinner_id
WHERE plan_days.date >= sqlc.arg(from_date) AND plan_days.date < sqlc.arg(to_date)
ORDER BY plan_days.date, plan_days.id;