diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-01-26 17:00:30 -1000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-01-26 17:00:30 -1000 |
| commit | bbf12fc441ca36c423e865107d34df178e3d26de (patch) | |
| tree | 44525ff1c846c1b4099f4c08c6ce88f6028ea5d2 /internal/store/sqlite.go | |
| parent | fd2524eacd51f523998734f869b3343441e55b93 (diff) | |
Fix multiple UI issues and shopping completion bug
- #54: Fix shopping item completion - now works for all sources
(trello, plantoeat, user) with state stored in local DB
- #48: Hide 12:00am times in timeline (all-day items)
- #49: Remove "Task" type label from timeline items for cleaner UI
- #51: Combine multiple PlanToEat meals for same date+mealType
- #52: Change Conditions tab to standard link to standalone page
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/store/sqlite.go')
| -rw-r--r-- | internal/store/sqlite.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/store/sqlite.go b/internal/store/sqlite.go index c2f6e98..396ac54 100644 --- a/internal/store/sqlite.go +++ b/internal/store/sqlite.go @@ -701,6 +701,40 @@ func (s *Store) DeleteUserShoppingItem(id int64) error { return err } +// SetShoppingItemChecked sets the checked state for an external shopping item +func (s *Store) SetShoppingItemChecked(source, itemID string, checked bool) error { + checkedInt := 0 + if checked { + checkedInt = 1 + } + _, err := s.db.Exec(` + INSERT INTO shopping_item_checks (source, item_id, checked, updated_at) + VALUES (?, ?, ?, CURRENT_TIMESTAMP) + ON CONFLICT(source, item_id) DO UPDATE SET checked = ?, updated_at = CURRENT_TIMESTAMP + `, source, itemID, checkedInt, checkedInt) + return err +} + +// GetShoppingItemChecks returns a map of item_id -> checked for a given source +func (s *Store) GetShoppingItemChecks(source string) (map[string]bool, error) { + rows, err := s.db.Query(`SELECT item_id, checked FROM shopping_item_checks WHERE source = ?`, source) + if err != nil { + return nil, err + } + defer func() { _ = rows.Close() }() + + checks := make(map[string]bool) + for rows.Next() { + var itemID string + var checked int + if err := rows.Scan(&itemID, &checked); err != nil { + return nil, err + } + checks[itemID] = checked == 1 + } + return checks, rows.Err() +} + // GetTasksByDateRange retrieves tasks due within a specific date range func (s *Store) GetTasksByDateRange(start, end time.Time) ([]models.Task, error) { rows, err := s.db.Query(` |
