diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-15 18:30:16 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-16 02:54:17 +0000 |
| commit | 37c323481d2e124e75bf3480dbc3bf53cad915e0 (patch) | |
| tree | 18dcd09b2d9114fc7e849a52f7409d6750999cd0 /internal/handlers/timeline_logic.go | |
| parent | b55c01eb9c48d2af754ff22c55deab6f0832e358 (diff) | |
feat(tasks): thread project color from BuildTimeline to WidgetItem
Projects are fetched once per BuildTimeline call into a color lookup
map, not queried per-task -- same pattern as RecurringEventID's
existing TimelineItem->WidgetItem threading.
Diffstat (limited to 'internal/handlers/timeline_logic.go')
| -rw-r--r-- | internal/handlers/timeline_logic.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/handlers/timeline_logic.go b/internal/handlers/timeline_logic.go index 6fddd1d..b90b61e 100644 --- a/internal/handlers/timeline_logic.go +++ b/internal/handlers/timeline_logic.go @@ -17,6 +17,16 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([ var items []models.TimelineItem now := config.Now() + // Fetch all projects once into a color lookup map + projectColors := make(map[string]string) + if projects, err := s.GetProjects(); err != nil { + log.Printf("Warning: failed to read projects: %v", err) + } else { + for _, p := range projects { + projectColors[p.ID] = p.Color + } + } + // 1. Fetch Meals - combine multiple items for same date+mealType meals, err := s.GetMealsByDateRange(start, end) if err != nil { @@ -147,6 +157,7 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([ OriginalItem: task, IsCompleted: task.Completed, Source: "doot", + ProjectColor: projectColors[task.ProjectID], } item.ComputeDaySection(now) items = append(items, item) @@ -170,6 +181,7 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([ OriginalItem: task, IsCompleted: task.Completed, Source: "doot", + ProjectColor: projectColors[task.ProjectID], } item.ComputeDaySection(now) items = append(items, item) @@ -191,6 +203,7 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([ IsCompleted: task.Completed, Source: "doot", IsAllDay: true, + ProjectColor: projectColors[task.ProjectID], } item.ComputeDaySection(now) items = append(items, item) |
