diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-01-12 14:05:27 -1000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-01-12 14:05:27 -1000 |
| commit | 9ef5b7f37883f846f105da9dc5d2ba1415e594e3 (patch) | |
| tree | 7b39b9328c1b649e6bb87fba3ed6734448046afb /internal/store | |
| parent | e57671031d0e792926d12701aace4ffbff6a5bdf (diff) | |
Sort Trello boards with active boards first
Improves UX by prioritizing boards with cards over empty boards.
Both API and cached results now sort consistently: non-empty boards
appear first, then empty boards, with alphabetical ordering within
each group.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/store')
| -rw-r--r-- | internal/store/sqlite.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/store/sqlite.go b/internal/store/sqlite.go index e2b0aee..5063336 100644 --- a/internal/store/sqlite.go +++ b/internal/store/sqlite.go @@ -424,9 +424,13 @@ func (s *Store) SaveBoards(boards []models.Board) error { // GetBoards retrieves all boards with their cards from the database func (s *Store) GetBoards() ([]models.Board, error) { - // Fetch boards + // Fetch boards, sorted by: non-empty boards first, then alphabetical boardRows, err := s.db.Query(` - SELECT id, name FROM boards ORDER BY name + SELECT b.id, b.name + FROM boards b + ORDER BY + CASE WHEN (SELECT COUNT(*) FROM cards c WHERE c.board_id = b.id) > 0 THEN 0 ELSE 1 END, + b.name `) if err != nil { return nil, err |
