summaryrefslogtreecommitdiff
path: root/internal/store/sqlite.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-18 15:47:51 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-18 15:47:51 -1000
commit791034f1b588bf679f45a0f89168515fcbde66d5 (patch)
treef7c75105ac4aa370bd22874dbe0bf976cba892ec /internal/store/sqlite.go
parent8dbb6f43577b8a86e94ef7aaee196f9743356643 (diff)
Fix Trello closed boards bug - filter API and clear stale cache
Closed boards were appearing because: 1. API fetched all boards including closed ones 2. Cache used upsert logic that never removed old data Fixes: - Add filter=open to GetBoards API call - Add filter=visible to GetCards API call - Clear boards/cards tables before inserting fresh data in SaveBoards Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/store/sqlite.go')
-rw-r--r--internal/store/sqlite.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/store/sqlite.go b/internal/store/sqlite.go
index 79f5cc8..259bd0f 100644
--- a/internal/store/sqlite.go
+++ b/internal/store/sqlite.go
@@ -418,6 +418,7 @@ func (s *Store) InvalidateCache(key string) error {
// Boards operations
// SaveBoards saves multiple boards to the database
+// This clears existing data and replaces it with the new data
func (s *Store) SaveBoards(boards []models.Board) error {
tx, err := s.db.Begin()
if err != nil {
@@ -425,6 +426,14 @@ func (s *Store) SaveBoards(boards []models.Board) error {
}
defer tx.Rollback()
+ // Clear existing data first (cards must be deleted before boards due to foreign key)
+ if _, err := tx.Exec(`DELETE FROM cards`); err != nil {
+ return err
+ }
+ if _, err := tx.Exec(`DELETE FROM boards`); err != nil {
+ return err
+ }
+
// Save boards
boardStmt, err := tx.Prepare(`
INSERT OR REPLACE INTO boards (id, name, updated_at)