From 9ef5b7f37883f846f105da9dc5d2ba1415e594e3 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 12 Jan 2026 14:05:27 -1000 Subject: 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 --- internal/api/trello.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'internal/api/trello.go') diff --git a/internal/api/trello.go b/internal/api/trello.go index cecf0dc..b9391d6 100644 --- a/internal/api/trello.go +++ b/internal/api/trello.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net/http" + "sort" "sync" "time" @@ -216,6 +217,16 @@ func (c *TrelloClient) GetBoardsWithCards(ctx context.Context) ([]models.Board, wg.Wait() + // Sort boards: Non-empty boards first, then alphabetical by name + sort.Slice(boards, func(i, j int) bool { + hasCardsI := len(boards[i].Cards) > 0 + hasCardsJ := len(boards[j].Cards) > 0 + if hasCardsI != hasCardsJ { + return hasCardsI // true (non-empty) comes before false + } + return boards[i].Name < boards[j].Name + }) + return boards, nil } -- cgit v1.2.3