diff options
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) |
