Files
MealQuest/internal/db/models.go
T
dev_agentandClaude Opus 5.5 c22470bf35
CI / ci (pull_request) Successful in 1m31s
Independent review Codex gpt-6-sol high: APPROVED (0 findings)
CI / ci (push) Successful in 2m8s
Seed household settings at boot and serve the settings API
Port of Feature 04 task 3 (7629cab) onto Feature 04 + Feature 03.

On first boot create the single household_settings row with the zone from
MEALQUEST_DEFAULT_TZ and the seed times and days (dinner 17:30, reminder
16:30, rotation check 09:00, plan draft Fri 09:00, suggestions Sun 08:00,
chat autosend Sat 08:00). An existing row is never overwritten.

Add household.SettingsService with Get, a validating Update (IANA zone,
zero-padded 24-hour HH:MM, day of week 0-6) that records updated_by, and
in-process Subscribe for the scheduler. Serve it as GET and PATCH
/api/v1/settings/household; invalid input is a 400 in the standard error
body. Migration 0002 adds household_settings.updated_by. Link time/tzdata
from internal/household so zones load in the minimal image.

Review fixes:
- F1: the settings routes are mounted on the protected /api/v1 subrouter,
  so they need a session (RequireSession) and, for PATCH, the CSRF token.
  updated_by is the session actor's subject from auth.ActorFrom; the
  duplicate internal/actor package is dropped, and Update refuses an empty
  member instead of storing NULL. A test drives PATCH through the
  production router with a real SessionManager session.
- F2: config no longer validates MEALQUEST_DEFAULT_TZ. Seeding requires a
  valid zone only when it creates the row (ErrNoDefaultZone,
  ErrInvalidDefaultZone, both naming the variable at boot), so a reboot
  over existing settings ignores a missing or invalid default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 11:42:35 -04:00

311 lines
6.0 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
package db
import (
"database/sql"
)
type AiRun struct {
ID string
Skill string
SkillVersion string
Provider string
Model string
Temperature float64
Status string
LatencyMs sql.NullInt64
TokensIn sql.NullInt64
TokensOut sql.NullInt64
Error sql.NullString
RequestRedacted string
ResponseRedacted sql.NullString
CreatedAt string
UpdatedAt string
}
type AiSetting struct {
ID int64
Provider string
BaseUrl string
Model string
Temperature float64
SystemPrompt sql.NullString
ApiKeyCt []byte
ApiKeyLast4 sql.NullString
KeyVerifiedAt sql.NullString
CreatedAt string
UpdatedAt string
}
type ChatSetting struct {
ID int64
WebhookUrlCt []byte
SpaceLabel sql.NullString
LastTestAt sql.NullString
LastTestStatus sql.NullString
CreatedAt string
UpdatedAt string
}
type Dinner struct {
ID string
Name string
NormalizedName string
Status string
Origin string
Method sql.NullString
MinutesTotal sql.NullInt64
Difficulty sql.NullString
Cuisine sql.NullString
IsFavorite int64
RecipeID sql.NullString
PhotoID sql.NullString
GroundingStatus string
UpdatedBy sql.NullString
CreatedAt string
UpdatedAt string
}
type HouseholdSetting struct {
ID int64
Timezone string
DinnerTime string
ReminderTime string
ReviewTime string
PlanDraftDow int64
PlanDraftTime string
SuggestionsDow int64
SuggestionsTime string
ChatAutosendDow int64
ChatAutosendTime string
OnboardingCompletedAt sql.NullString
UpdatesSeenAt sql.NullString
CreatedAt string
UpdatedAt string
UpdatedBy sql.NullString
}
type IntegrationsGoogle struct {
ID int64
RefreshTokenCt []byte
CalendarID sql.NullString
CalendarName sql.NullString
ConnectedAt string
LastSyncError sql.NullString
CreatedAt string
UpdatedAt string
}
type Job struct {
ID string
Kind string
Status string
Payload string
Result sql.NullString
Error sql.NullString
StartedAt sql.NullString
FinishedAt sql.NullString
CreatedAt string
UpdatedAt string
}
type NotificationOutbox struct {
ID string
EventKey string
Channel string
Payload string
Status string
Attempts int64
NextAttemptAt sql.NullString
LastError sql.NullString
CreatedAt string
UpdatedAt string
}
type NotificationPref struct {
Event string
Push int64
Chat int64
CreatedAt string
UpdatedAt string
}
type Photo struct {
ID string
SourceUrl string
LocalPath string
Width int64
Height int64
Sha256 string
FetchedAt string
CreatedAt string
UpdatedAt string
}
type PlanDay struct {
ID string
PlanID string
Date string
DinnerID sql.NullString
IsNew int64
CalendarEventID sql.NullString
CreatedAt string
UpdatedAt string
}
type PushSubscription struct {
ID string
Endpoint string
P256dh string
Auth string
UserAgent sql.NullString
FailureCount int64
LastSuccessAt sql.NullString
CreatedAt string
UpdatedAt string
}
type Recipe struct {
ID string
SourceUrl string
SiteName sql.NullString
Title string
TotalMinutes sql.NullInt64
PrepMinutes sql.NullInt64
CookMinutes sql.NullInt64
Yield sql.NullString
RawJsonld string
FetchedAt string
CreatedAt string
UpdatedAt string
}
type RecipeIngredient struct {
ID string
RecipeID string
Position int64
RawText string
Name sql.NullString
Qty sql.NullString
Unit sql.NullString
Note sql.NullString
CreatedAt string
UpdatedAt string
}
type RecipeSearchSetting struct {
ID int64
Provider string
BaseUrl sql.NullString
ApiKeyCt []byte
CreatedAt string
UpdatedAt string
}
type RecipeStep struct {
ID string
RecipeID string
Position int64
Text string
CreatedAt string
UpdatedAt string
}
type RotationReview struct {
ID string
DinnerID string
PlanDate string
Status string
Decision sql.NullString
DecidedAt sql.NullString
UpdatedBy sql.NullString
CreatedAt string
UpdatedAt string
}
type ScheduleRun struct {
ID string
Schedule string
PeriodKey string
CreatedAt string
}
type Session struct {
IDHash string
Subject string
Email string
Name string
Groups string
CsrfToken string
CreatedAt string
LastSeenAt string
ExpiresAt string
}
type ShoppingGroup struct {
ID string
ListID string
DinnerID string
Position int64
CreatedAt string
UpdatedAt string
}
type ShoppingItem struct {
ID string
GroupID string
Name string
Qty sql.NullString
Needed int64
Position int64
CreatedAt string
UpdatedAt string
}
type ShoppingList struct {
ID string
WeekStart string
PlanID string
Title string
Status string
SentToChatAt sql.NullString
FrozenAt sql.NullString
CreatedAt string
UpdatedAt string
}
type Suggestion struct {
ID string
DinnerID string
BatchID string
Reason string
CitedRegularIds string
Status string
DecidedAt sql.NullString
CreatedAt string
UpdatedAt string
}
type SuggestionBatch struct {
ID string
Trigger string
Status string
AiRunID sql.NullString
CreatedAt string
UpdatedAt string
}
type WeekPlan struct {
ID string
WeekStart string
Status string
AiNote sql.NullString
AiRunID sql.NullString
CalendarSyncedAt sql.NullString
CreatedAt string
UpdatedAt string
}