From 42a4e32daca13b518e64e5821080ff3d6adf0e39 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 26 Jan 2026 16:49:44 -1000 Subject: Use configured timezone throughout codebase - Add config/timezone.go with timezone utilities: - SetDisplayTimezone(), GetDisplayTimezone() - Now(), Today() - current time/date in display TZ - ParseDateInDisplayTZ(), ToDisplayTZ() - parsing helpers - Initialize timezone at startup in main.go - Update all datetime logic to use configured timezone: - handlers/handlers.go - all time.Now() calls - handlers/timeline.go - date parsing - handlers/timeline_logic.go - now calculation - models/atom.go - ComputeUIFields() - models/timeline.go - ComputeDaySection() - api/plantoeat.go - meal date parsing - api/todoist.go - due date parsing - api/trello.go - due date parsing This ensures all dates/times display correctly regardless of server timezone setting. Co-Authored-By: Claude Opus 4.5 --- TIMELINE_DESIGN.md | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 TIMELINE_DESIGN.md (limited to 'TIMELINE_DESIGN.md') diff --git a/TIMELINE_DESIGN.md b/TIMELINE_DESIGN.md new file mode 100644 index 0000000..61c71b5 --- /dev/null +++ b/TIMELINE_DESIGN.md @@ -0,0 +1,82 @@ +# Timeline Feature Design + +## Objective +Create a unified timeline view showing Tasks, Meals, Trello Cards, and Google Calendar Events, sorted chronologically. + +## Data Sources +1. **Tasks (Todoist):** From DB `tasks` table. Filter: `due_date` is not null. +2. **Meals (PlanToEat):** From DB `meals` table. Filter: `date` is not null. +3. **Cards (Trello):** From DB `cards` table. Filter: `due_date` is not null. +4. **Google Calendar Events:** From `GoogleCalendarClient` (Live API). + +## Backend Logic + +### 1. Data Models (`internal/models/timeline.go`) +We need a polymorphic structure to hold different item types. + +```go +type TimelineItemType string + +const ( + ItemTypeTask TimelineItemType = "task" + ItemTypeMeal TimelineItemType = "meal" + ItemTypeCard TimelineItemType = "card" + ItemTypeEvent TimelineItemType = "event" +) + +type TimelineItem struct { + ID string `json:"id"` + Type TimelineItemType `json:"type"` + Title string `json:"title"` + Description string `json:"description"` + Time time.Time `json:"time"` + AllDay bool `json:"all_day"` + URL string `json:"url"` + Meta map[string]any `json:"meta"` // Extra data like ProjectName, RecipeURL, etc. +} +``` + +### 2. Store Extensions (`internal/store/`) +Add methods to fetch items by date range. +* `GetTasksByDateRange(start, end time.Time) ([]models.Task, error)` +* `GetMealsByDateRange(start, end time.Time) ([]models.Meal, error)` +* `GetCardsByDateRange(start, end time.Time) ([]models.Card, error)` + +### 3. Logic Layer (`internal/handlers/timeline_logic.go`) +* **Function:** `BuildTimeline(store Store, calendarClient *api.GoogleCalendarClient, start, end time.Time) ([]TimelineItem, error)` +* **Aggregation:** + 1. Fetch from Store (Tasks, Meals, Cards). + 2. Fetch from Calendar API. + 3. Convert all to `TimelineItem`. + 4. **Meal Time Defaults:** + * Breakfast: 08:00 + * Lunch: 12:00 + * Dinner: 19:00 + * Other: 12:00 + 5. Sort by `Time`. + +### 4. HTTP Handler (`internal/handlers/timeline.go`) +* **Route:** `GET /timeline` +* **Params:** `start` (default: today), `days` (default: 7) +* **Response:** Render `timeline-tab.html` partial. + +## UI Design (`web/templates/partials/timeline-tab.html`) +* **Structure:** + * Container + * Loop through Days + * Date Header (e.g., "Mon, Jan 2") + * List of Items + * Time Column (e.g., "14:00") + * Content Column (Icon + Title + Subtitle) +* **Styling:** + * Use existing CSS variables. + * Distinct icons/colors for Tasks vs Meals vs Events. + +## Files to Modify +1. `internal/models/timeline.go` (New) +2. `internal/store/store.go` (Interface update) +3. `internal/store/sqlite.go` (Implementation update) +4. `internal/handlers/timeline_logic.go` (New) +5. `internal/handlers/timeline.go` (New) +6. `web/templates/partials/timeline-tab.html` (New) +7. `cmd/dashboard/main.go` (Route registration) -- cgit v1.2.3