Fix date comparison for cross-DB compatibility and add timezone coverage

- Change all date scopes from PostgreSQL-specific ::date to DATE() function
  which works in both PostgreSQL and SQLite (used in tests)
- Fix ScopeOverdue, ScopeDueSoon, ScopeUpcoming, ScopeDueInRange
- Fix GetOverdueTasks inline query in task_repo.go

- Fix timezone unit tests: due dates must be stored as midnight UTC
  (calendar dates), not with timezone info that GORM converts to UTC
- Update TestGetOverdueTasks_Timezone_Tokyo, NewYork, InternationalDateLine
- Update TestGetDueSoonTasks_Timezone_DST

- Add TestIntegration_TimezoneDivergence: proves same task appears in
  different kanban columns based on X-Timezone header
- Update TestIntegration_DateBoundaryEdgeCases to use America/New_York
- Update TestIntegration_TasksByResidenceKanban to use America/Los_Angeles
- Add identity-based column membership assertions (columnTaskIDs approach)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-16 14:59:12 -06:00
parent 6dac34e373
commit 9bd0708ca4
4 changed files with 508 additions and 111 deletions

View File

@@ -110,10 +110,11 @@ func (r *TaskRepository) GetOverdueTasks(now time.Time, opts TaskFilterOptions)
if opts.IncludeArchived {
// When including archived, build the query manually to skip the archived check
// but still apply cancelled check, not-completed check, and date check
startOfDay := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
// IMPORTANT: Use date comparison (not timestamps) for timezone correctness
todayStr := now.Format("2006-01-02")
query = query.Where("is_cancelled = ?", false).
Scopes(task.ScopeNotCompleted).
Where("COALESCE(next_due_date, due_date) < ?", startOfDay)
Where("DATE(COALESCE(next_due_date, due_date)) < DATE(?)", todayStr)
} else {
// Use the combined scope which includes is_archived = false
query = query.Scopes(task.ScopeOverdue(now))