summaryrefslogtreecommitdiff
path: root/internal/handlers/timeline_logic.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/timeline_logic.go')
-rw-r--r--internal/handlers/timeline_logic.go36
1 files changed, 27 insertions, 9 deletions
diff --git a/internal/handlers/timeline_logic.go b/internal/handlers/timeline_logic.go
index 1aba780..c51262a 100644
--- a/internal/handlers/timeline_logic.go
+++ b/internal/handlers/timeline_logic.go
@@ -13,6 +13,7 @@ import (
// BuildTimeline aggregates and normalizes data into a timeline structure
func BuildTimeline(ctx context.Context, s *store.Store, calendarClient api.GoogleCalendarAPI, start, end time.Time) ([]models.TimelineItem, error) {
var items []models.TimelineItem
+ now := time.Now()
// 1. Fetch Tasks
tasks, err := s.GetTasksByDateRange(start, end)
@@ -23,7 +24,7 @@ func BuildTimeline(ctx context.Context, s *store.Store, calendarClient api.Googl
if task.DueDate == nil {
continue
}
- items = append(items, models.TimelineItem{
+ item := models.TimelineItem{
ID: task.ID,
Type: models.TimelineItemTypeTask,
Title: task.Content,
@@ -31,7 +32,11 @@ func BuildTimeline(ctx context.Context, s *store.Store, calendarClient api.Googl
Description: task.Description,
URL: task.URL,
OriginalItem: task,
- })
+ IsCompleted: task.Completed,
+ Source: "todoist",
+ }
+ item.ComputeDaySection(now)
+ items = append(items, item)
}
// 2. Fetch Meals
@@ -53,14 +58,18 @@ func BuildTimeline(ctx context.Context, s *store.Store, calendarClient api.Googl
mealTime = time.Date(mealTime.Year(), mealTime.Month(), mealTime.Day(), 12, 0, 0, 0, mealTime.Location())
}
- items = append(items, models.TimelineItem{
+ item := models.TimelineItem{
ID: meal.ID,
Type: models.TimelineItemTypeMeal,
Title: meal.RecipeName,
Time: mealTime,
URL: meal.RecipeURL,
OriginalItem: meal,
- })
+ IsCompleted: false, // Meals don't have completion status
+ Source: "plantoeat",
+ }
+ item.ComputeDaySection(now)
+ items = append(items, item)
}
// 3. Fetch Cards
@@ -72,14 +81,18 @@ func BuildTimeline(ctx context.Context, s *store.Store, calendarClient api.Googl
if card.DueDate == nil {
continue
}
- items = append(items, models.TimelineItem{
+ item := models.TimelineItem{
ID: card.ID,
Type: models.TimelineItemTypeCard,
Title: card.Name,
Time: *card.DueDate,
URL: card.URL,
OriginalItem: card,
- })
+ IsCompleted: false, // Cards in timeline are not completed (closed cards filtered out)
+ Source: "trello",
+ }
+ item.ComputeDaySection(now)
+ items = append(items, item)
}
// 4. Fetch Events
@@ -87,16 +100,21 @@ func BuildTimeline(ctx context.Context, s *store.Store, calendarClient api.Googl
events, err := calendarClient.GetEventsByDateRange(ctx, start, end)
if err == nil {
for _, event := range events {
- items = append(items, models.TimelineItem{
+ endTime := event.End
+ item := models.TimelineItem{
ID: event.ID,
Type: models.TimelineItemTypeEvent,
Title: event.Summary,
Time: event.Start,
- EndTime: &event.End,
+ EndTime: &endTime,
Description: event.Description,
URL: event.HTMLLink,
OriginalItem: event,
- })
+ IsCompleted: false, // Events don't have completion status
+ Source: "calendar",
+ }
+ item.ComputeDaySection(now)
+ items = append(items, item)
}
}
}