From 143166ce759ce2cb0133b7438db36b844a9db1a7 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sun, 18 Jan 2026 14:06:26 -1000 Subject: Implement Trello task heuristics for Tasks tab (Phase 3 Step 6) Add filtering logic to show Trello cards as actionable tasks when they have due dates OR are in lists named like "todo", "doing", "in progress", "tasks", "next", or "today". This makes the Tasks tab more useful by surfacing cards that represent work items even without explicit due dates. Co-Authored-By: Claude Opus 4.5 --- internal/handlers/handlers.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'internal/handlers/handlers.go') diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index c3e49ed..9ba6351 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -6,6 +6,8 @@ import ( "html/template" "log" "net/http" + "sort" + "strings" "sync" "time" @@ -302,6 +304,47 @@ func (h *Handler) aggregateData(ctx context.Context, forceRefresh bool) (*models wg.Wait() + // Filter Trello cards into tasks based on heuristic + var trelloTasks []models.Card + for _, board := range data.Boards { + for _, card := range board.Cards { + listNameLower := strings.ToLower(card.ListName) + isTask := card.DueDate != nil || + strings.Contains(listNameLower, "todo") || + strings.Contains(listNameLower, "doing") || + strings.Contains(listNameLower, "progress") || + strings.Contains(listNameLower, "task") + + if isTask { + trelloTasks = append(trelloTasks, card) + } + } + } + + // Sort trelloTasks: earliest due date first, nil last, then by board name + sort.Slice(trelloTasks, func(i, j int) bool { + // Both have due dates: compare dates + if trelloTasks[i].DueDate != nil && trelloTasks[j].DueDate != nil { + if !trelloTasks[i].DueDate.Equal(*trelloTasks[j].DueDate) { + return trelloTasks[i].DueDate.Before(*trelloTasks[j].DueDate) + } + // Same due date, fall through to board name comparison + } + + // Only one has due date: that one comes first + if trelloTasks[i].DueDate != nil && trelloTasks[j].DueDate == nil { + return true + } + if trelloTasks[i].DueDate == nil && trelloTasks[j].DueDate != nil { + return false + } + + // Both nil or same due date: sort by board name + return trelloTasks[i].BoardName < trelloTasks[j].BoardName + }) + + data.TrelloTasks = trelloTasks + return data, nil } -- cgit v1.2.3