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.go56
1 files changed, 25 insertions, 31 deletions
diff --git a/internal/handlers/timeline_logic.go b/internal/handlers/timeline_logic.go
index 145e851..8430ee9 100644
--- a/internal/handlers/timeline_logic.go
+++ b/internal/handlers/timeline_logic.go
@@ -7,14 +7,13 @@ import (
"strings"
"time"
- "task-dashboard/internal/api"
"task-dashboard/internal/config"
"task-dashboard/internal/models"
"task-dashboard/internal/store"
)
// BuildTimeline aggregates and normalizes data into a timeline structure
-func BuildTimeline(ctx context.Context, s *store.Store, tasksClient api.GoogleTasksAPI, start, end time.Time) ([]models.TimelineItem, error) {
+func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([]models.TimelineItem, error) {
var items []models.TimelineItem
now := config.Now()
@@ -145,37 +144,32 @@ func BuildTimeline(ctx context.Context, s *store.Store, tasksClient api.GoogleTa
}
}
- // 5. Fetch Google Tasks
- if tasksClient != nil {
- gTasks, err := tasksClient.GetTasksByDateRange(ctx, start, end)
- if err != nil {
- log.Printf("Warning: failed to fetch Google Tasks: %v", err)
- } else {
- log.Printf("Google Tasks: fetched %d tasks in date range", len(gTasks))
- for _, gTask := range gTasks {
- // Tasks without due date are placed in today section
- taskTime := now
- if gTask.DueDate != nil {
- taskTime = *gTask.DueDate
- }
- item := models.TimelineItem{
- ID: gTask.ID,
- Type: models.TimelineItemTypeGTask,
- Title: gTask.Title,
- Time: taskTime,
- Description: gTask.Notes,
- URL: gTask.URL,
- OriginalItem: gTask,
- IsCompleted: gTask.Completed,
- Source: "gtasks",
- ListID: gTask.ListID,
- }
- item.ComputeDaySection(now)
- items = append(items, item)
+ // 5. Fetch Google Tasks from store cache
+ gTasks, err := s.GetGoogleTasksByDateRange(start, end)
+ if err != nil {
+ log.Printf("Warning: failed to read cached Google Tasks: %v", err)
+ } else {
+ for _, gTask := range gTasks {
+ // Tasks without due date are placed in today section
+ taskTime := now
+ if gTask.DueDate != nil {
+ taskTime = *gTask.DueDate
+ }
+ item := models.TimelineItem{
+ ID: gTask.ID,
+ Type: models.TimelineItemTypeGTask,
+ Title: gTask.Title,
+ Time: taskTime,
+ Description: gTask.Notes,
+ URL: gTask.URL,
+ OriginalItem: gTask,
+ IsCompleted: gTask.Completed,
+ Source: "gtasks",
+ ListID: gTask.ListID,
}
+ item.ComputeDaySection(now)
+ items = append(items, item)
}
- } else {
- log.Printf("Google Tasks client not configured")
}
// Sort items by Time