diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-23 08:13:02 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-23 08:13:02 +0000 |
| commit | b2d8fc460be3105ac383098e7cdc92171e5026ec (patch) | |
| tree | cd5ba3f3008e6b3310680d785880f1f32ed090c5 /internal/handlers/timeline_logic.go | |
| parent | b0688c8819da1b7fcb4a97b6ec1fa58050e4841e (diff) | |
feat: unify Google Tasks with main system via caching and integrated UI
- Implement SQLite caching layer for Google Tasks
- Integrate Google Tasks into unified Atoms loop (showing in Tasks tab)
- Update Planning tab to include cached Google Tasks
- Enhance Quick Add form with Todoist project selector
- Remove orphaned HandleTasksTab/HandleRefreshTab methods
- Update tests to reflect new BuildTimeline signature and data structures
Diffstat (limited to 'internal/handlers/timeline_logic.go')
| -rw-r--r-- | internal/handlers/timeline_logic.go | 56 |
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 |
