Fix residence overdue count to exclude in-progress tasks
GetOverdueCountByResidence now uses ScopeNotInProgress to match the kanban overdue column behavior. This ensures the overdue count shown on residence cards matches what's displayed in the task board. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -635,6 +635,7 @@ func (r *TaskRepository) FindCompletionImageByID(id uint) (*models.TaskCompletio
|
||||
|
||||
// GetOverdueCountByResidence returns a map of residence ID to overdue task count.
|
||||
// Uses the task.scopes package for consistent filtering logic.
|
||||
// Excludes in-progress tasks to match what's displayed in the kanban overdue column.
|
||||
// The `now` parameter should be the start of day in the user's timezone for accurate overdue detection.
|
||||
func (r *TaskRepository) GetOverdueCountByResidence(residenceIDs []uint, now time.Time) (map[uint]int, error) {
|
||||
if len(residenceIDs) == 0 {
|
||||
@@ -650,7 +651,7 @@ func (r *TaskRepository) GetOverdueCountByResidence(residenceIDs []uint, now tim
|
||||
|
||||
err := r.db.Model(&models.Task{}).
|
||||
Select("residence_id, COUNT(*) as count").
|
||||
Scopes(task.ScopeForResidences(residenceIDs), task.ScopeOverdue(now)).
|
||||
Scopes(task.ScopeForResidences(residenceIDs), task.ScopeOverdue(now), task.ScopeNotInProgress).
|
||||
Group("residence_id").
|
||||
Scan(&results).Error
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user