Migrate from Gin to Echo framework and add comprehensive integration tests
Major changes: - Migrate all handlers from Gin to Echo framework - Add new apperrors, echohelpers, and validator packages - Update middleware for Echo compatibility - Add ArchivedHandler to task categorization chain (archived tasks go to cancelled_tasks column) - Add 6 new integration tests: - RecurringTaskLifecycle: NextDueDate advancement for weekly/monthly tasks - MultiUserSharing: Complex sharing with user removal - TaskStateTransitions: All state transitions and kanban column changes - DateBoundaryEdgeCases: Threshold boundary testing - CascadeOperations: Residence deletion cascade effects - MultiUserOperations: Shared residence collaboration - Add single-purpose repository functions for kanban columns (GetOverdueTasks, GetDueSoonTasks, etc.) - Fix RemoveUser route param mismatch (userId -> user_id) - Fix determineExpectedColumn helper to correctly prioritize in_progress over overdue 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -91,16 +91,18 @@ func EffectiveDate(task *models.Task) *time.Time {
|
||||
return task.DueDate
|
||||
}
|
||||
|
||||
// IsOverdue returns true if the task's effective date is in the past.
|
||||
// IsOverdue returns true if the task's effective date is before today.
|
||||
//
|
||||
// A task is overdue when:
|
||||
// - It has an effective date (NextDueDate or DueDate)
|
||||
// - That date is before the given time
|
||||
// - That date is before the start of the current day
|
||||
// - The task is not completed, cancelled, or archived
|
||||
//
|
||||
// Note: A task due "today" is NOT overdue. It becomes overdue tomorrow.
|
||||
//
|
||||
// SQL equivalent (in scopes.go ScopeOverdue):
|
||||
//
|
||||
// COALESCE(next_due_date, due_date) < ?
|
||||
// COALESCE(next_due_date, due_date) < DATE_TRUNC('day', ?)
|
||||
// AND NOT (next_due_date IS NULL AND EXISTS completion)
|
||||
// AND is_cancelled = false AND is_archived = false
|
||||
func IsOverdue(task *models.Task, now time.Time) bool {
|
||||
@@ -111,20 +113,25 @@ func IsOverdue(task *models.Task, now time.Time) bool {
|
||||
if effectiveDate == nil {
|
||||
return false
|
||||
}
|
||||
return effectiveDate.Before(now)
|
||||
// Compare against start of today, not current time
|
||||
// A task due "today" should not be overdue until tomorrow
|
||||
startOfDay := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
||||
return effectiveDate.Before(startOfDay)
|
||||
}
|
||||
|
||||
// IsDueSoon returns true if the task's effective date is within the threshold.
|
||||
//
|
||||
// A task is "due soon" when:
|
||||
// - It has an effective date (NextDueDate or DueDate)
|
||||
// - That date is >= now AND < (now + daysThreshold)
|
||||
// - That date is >= start of today AND < start of (today + daysThreshold)
|
||||
// - The task is not completed, cancelled, archived, or already overdue
|
||||
//
|
||||
// Note: Uses start of day for comparisons so tasks due "today" are included.
|
||||
//
|
||||
// SQL equivalent (in scopes.go ScopeDueSoon):
|
||||
//
|
||||
// COALESCE(next_due_date, due_date) >= ?
|
||||
// AND COALESCE(next_due_date, due_date) < ?
|
||||
// COALESCE(next_due_date, due_date) >= DATE_TRUNC('day', ?)
|
||||
// AND COALESCE(next_due_date, due_date) < DATE_TRUNC('day', ?) + interval 'N days'
|
||||
// AND NOT (next_due_date IS NULL AND EXISTS completion)
|
||||
// AND is_cancelled = false AND is_archived = false
|
||||
func IsDueSoon(task *models.Task, now time.Time, daysThreshold int) bool {
|
||||
@@ -135,18 +142,22 @@ func IsDueSoon(task *models.Task, now time.Time, daysThreshold int) bool {
|
||||
if effectiveDate == nil {
|
||||
return false
|
||||
}
|
||||
threshold := now.AddDate(0, 0, daysThreshold)
|
||||
// Due soon = not overdue AND before threshold
|
||||
return !effectiveDate.Before(now) && effectiveDate.Before(threshold)
|
||||
// Use start of day for comparisons
|
||||
startOfDay := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
||||
threshold := startOfDay.AddDate(0, 0, daysThreshold)
|
||||
// Due soon = not overdue (>= start of today) AND before threshold
|
||||
return !effectiveDate.Before(startOfDay) && effectiveDate.Before(threshold)
|
||||
}
|
||||
|
||||
// IsUpcoming returns true if the task is due after the threshold or has no due date.
|
||||
//
|
||||
// A task is "upcoming" when:
|
||||
// - It has no effective date, OR
|
||||
// - Its effective date is >= (now + daysThreshold)
|
||||
// - Its effective date is >= start of (today + daysThreshold)
|
||||
// - The task is not completed, cancelled, or archived
|
||||
//
|
||||
// Note: Uses start of day for comparisons for consistency with other predicates.
|
||||
//
|
||||
// This is the default category for tasks that don't match other criteria.
|
||||
func IsUpcoming(task *models.Task, now time.Time, daysThreshold int) bool {
|
||||
if !IsActive(task) || IsCompleted(task) {
|
||||
@@ -156,7 +167,9 @@ func IsUpcoming(task *models.Task, now time.Time, daysThreshold int) bool {
|
||||
if effectiveDate == nil {
|
||||
return true // No due date = upcoming
|
||||
}
|
||||
threshold := now.AddDate(0, 0, daysThreshold)
|
||||
// Use start of day for comparisons
|
||||
startOfDay := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
||||
threshold := startOfDay.AddDate(0, 0, daysThreshold)
|
||||
return !effectiveDate.Before(threshold)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user