summaryrefslogtreecommitdiff
path: root/internal/handlers/handlers.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-18 14:06:26 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-18 14:06:26 -1000
commit143166ce759ce2cb0133b7438db36b844a9db1a7 (patch)
treec7adf1243a9927f568f5937f95419a1b4b61a709 /internal/handlers/handlers.go
parent9cee3f78483532828a2f72c65eb2b952b2ded670 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/handlers/handlers.go')
-rw-r--r--internal/handlers/handlers.go43
1 files changed, 43 insertions, 0 deletions
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
}