summaryrefslogtreecommitdiff
path: root/internal/store/native_tasks.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-12 07:40:30 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-12 07:40:30 +0000
commitf01b2924bf0b62fc20af0d09581d101418455b1c (patch)
tree703bed9c8286fa4f48c5085c2a95268f9c6b07b7 /internal/store/native_tasks.go
parentaf0d59d78524127f6cc76e43a7e397da01788d97 (diff)
fix(timeline): include overdue native tasks in timeline and widget
GetNativeTasksByDateRange's SQL bound (due_date >= start) excluded any task overdue from a previous day before ComputeDaySection ever got a chance to mark it IsOverdue, so both the web Timeline view and the widget API (which both call BuildTimeline with start = today) silently dropped overdue tasks entirely -- only the Tasks tab (unbounded GetNativeTasks) showed them. Added GetOverdueNativeTasks and folded its results into BuildTimeline alongside the ranged fetch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTUSAEKfsPc6WGDq45yPHD
Diffstat (limited to 'internal/store/native_tasks.go')
-rw-r--r--internal/store/native_tasks.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/store/native_tasks.go b/internal/store/native_tasks.go
index 6f8f999..f43a160 100644
--- a/internal/store/native_tasks.go
+++ b/internal/store/native_tasks.go
@@ -46,6 +46,26 @@ func (s *Store) GetNativeTasksByDateRange(start, end time.Time) ([]models.Task,
return scanNativeTasks(rows)
}
+// GetOverdueNativeTasks returns non-completed native tasks whose due date is
+// before the given time. BuildTimeline calls this alongside
+// GetNativeTasksByDateRange, whose lower bound excludes anything due before
+// the requested range's start -- without this, a task overdue from a
+// previous day never gets fetched at all, so it never reaches
+// ComputeDaySection to be marked IsOverdue.
+func (s *Store) GetOverdueNativeTasks(before time.Time) ([]models.Task, error) {
+ rows, err := s.db.Query(`
+ SELECT id, content, description, project_name, due_date, priority, completed, labels, created_at
+ FROM native_tasks
+ WHERE completed = 0 AND due_date IS NOT NULL AND due_date < ?
+ ORDER BY due_date ASC, priority DESC
+ `, before)
+ if err != nil {
+ return nil, err
+ }
+ defer func() { _ = rows.Close() }()
+ return scanNativeTasks(rows)
+}
+
// GetUndatedNativeTasks returns non-completed native tasks with no due date.
func (s *Store) GetUndatedNativeTasks() ([]models.Task, error) {
rows, err := s.db.Query(`