summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/api/trello.go4
-rw-r--r--internal/store/sqlite.go9
2 files changed, 11 insertions, 2 deletions
diff --git a/internal/api/trello.go b/internal/api/trello.go
index 7140f79..be5d81b 100644
--- a/internal/api/trello.go
+++ b/internal/api/trello.go
@@ -64,7 +64,7 @@ type trelloListResponse struct {
// GetBoards fetches all boards for the authenticated user
func (c *TrelloClient) GetBoards(ctx context.Context) ([]models.Board, error) {
- url := fmt.Sprintf("%s/members/me/boards?key=%s&token=%s", c.baseURL, c.apiKey, c.token)
+ url := fmt.Sprintf("%s/members/me/boards?key=%s&token=%s&filter=open", c.baseURL, c.apiKey, c.token)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
@@ -103,7 +103,7 @@ func (c *TrelloClient) GetBoards(ctx context.Context) ([]models.Board, error) {
// GetCards fetches all cards for a specific board
func (c *TrelloClient) GetCards(ctx context.Context, boardID string) ([]models.Card, error) {
- url := fmt.Sprintf("%s/boards/%s/cards?key=%s&token=%s", c.baseURL, boardID, c.apiKey, c.token)
+ url := fmt.Sprintf("%s/boards/%s/cards?key=%s&token=%s&filter=visible", c.baseURL, boardID, c.apiKey, c.token)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
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)