Remove remaining status_id references after in_progress migration
- Remove Preload("Status") from worker handler and repositories
- Update seeds to use in_progress boolean instead of status_id
- Remove task_taskstatus table creation from lookup seeds
- Update documentation to reflect in_progress boolean pattern
Fixes notification worker error:
"Status: unsupported relations for schema Task"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ predicates.IsCompleted(task) // NextDueDate == nil && len(Completions) > 0
|
||||
predicates.IsActive(task) // !IsCancelled && !IsArchived
|
||||
predicates.IsCancelled(task) // IsCancelled == true
|
||||
predicates.IsArchived(task) // IsArchived == true
|
||||
predicates.IsInProgress(task) // Status.Name == "In Progress"
|
||||
predicates.IsInProgress(task) // InProgress == true
|
||||
|
||||
// Date calculations
|
||||
predicates.EffectiveDate(task) // NextDueDate ?? DueDate
|
||||
@@ -105,7 +105,7 @@ These rules are defined in `predicates/predicates.go` and enforced everywhere:
|
||||
|---------|------------|----------------|
|
||||
| **Completed** | `NextDueDate == nil && len(Completions) > 0` | `next_due_date IS NULL AND EXISTS (SELECT 1 FROM task_taskcompletion WHERE task_id = ?)` |
|
||||
| **Active** | `!IsCancelled && !IsArchived` | `is_cancelled = false AND is_archived = false` |
|
||||
| **In Progress** | `Status.Name == "In Progress"` | `JOIN task_taskstatus WHERE name = 'In Progress'` |
|
||||
| **In Progress** | `InProgress == true` | `in_progress = true` |
|
||||
| **Effective Date** | `NextDueDate ?? DueDate` | `COALESCE(next_due_date, due_date)` |
|
||||
| **Overdue** | `Active && !Completed && EffectiveDate < now` | Active + NotCompleted + `COALESCE(...) < ?` |
|
||||
| **Due Soon** | `Active && !Completed && now <= EffectiveDate < threshold` | Active + NotCompleted + `COALESCE(...) >= ? AND COALESCE(...) < ?` |
|
||||
@@ -117,7 +117,7 @@ When categorizing a task, the chain evaluates in this priority order:
|
||||
|
||||
1. **Cancelled** (highest) - `IsCancelled == true`
|
||||
2. **Completed** - `NextDueDate == nil && len(Completions) > 0`
|
||||
3. **In Progress** - `Status.Name == "In Progress"`
|
||||
3. **In Progress** - `InProgress == true`
|
||||
4. **Overdue** - `EffectiveDate < now`
|
||||
5. **Due Soon** - `now <= EffectiveDate < threshold`
|
||||
6. **Upcoming** (lowest/default) - Everything else
|
||||
@@ -139,7 +139,7 @@ db.Model(&models.Task{}).
|
||||
```go
|
||||
// Load tasks with preloads
|
||||
var tasks []models.Task
|
||||
db.Preload("Status").Preload("Completions").
|
||||
db.Preload("Completions").
|
||||
Scopes(task.ScopeForResidence(residenceID)).
|
||||
Find(&tasks)
|
||||
|
||||
@@ -329,18 +329,14 @@ db.Preload("Completions").Find(&tasks)
|
||||
predicates.IsCompleted(task) // Correct result
|
||||
```
|
||||
|
||||
### Forgetting to Preload Status
|
||||
### In Progress Boolean Field
|
||||
|
||||
The `IsInProgress` predicate checks `task.Status.Name == "In Progress"`. Without preloading:
|
||||
The `IsInProgress` predicate now uses a simple boolean field instead of a Status relation:
|
||||
|
||||
```go
|
||||
// BAD: Status not loaded
|
||||
db.Find(&tasks)
|
||||
predicates.IsInProgress(task) // Nil pointer or always false
|
||||
|
||||
// GOOD: Preload status
|
||||
db.Preload("Status").Find(&tasks)
|
||||
predicates.IsInProgress(task) // Correct result
|
||||
// IsInProgress uses the in_progress boolean field directly
|
||||
// No preloading required for this check
|
||||
predicates.IsInProgress(task) // Checks task.InProgress boolean
|
||||
```
|
||||
|
||||
## Quick Reference Import
|
||||
|
||||
Reference in New Issue
Block a user