summaryrefslogtreecommitdiff
path: root/internal/store/native_tasks.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/store/native_tasks.go')
-rw-r--r--internal/store/native_tasks.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/internal/store/native_tasks.go b/internal/store/native_tasks.go
index ea5212c..955b7ac 100644
--- a/internal/store/native_tasks.go
+++ b/internal/store/native_tasks.go
@@ -43,7 +43,7 @@ func (s *Store) GetNativeTasks() ([]models.Task, error) {
chain_id, chain_position, chain_unlocked,
bucket_id, bucket_state, bucket_last_active_at
FROM native_tasks
- WHERE completed = 0
+ WHERE completed = 0 AND abandoned = 0
ORDER BY CASE WHEN due_date IS NULL THEN 1 ELSE 0 END, due_date ASC, priority DESC
`)
if err != nil {
@@ -64,7 +64,7 @@ func (s *Store) GetNativeTasksByDateRange(start, end time.Time) ([]models.Task,
chain_id, chain_position, chain_unlocked,
bucket_id, bucket_state, bucket_last_active_at
FROM native_tasks t
- WHERE completed = 0 AND due_date IS NOT NULL AND due_date >= ? AND due_date < ?
+ WHERE completed = 0 AND abandoned = 0 AND due_date IS NOT NULL AND due_date >= ? AND due_date < ?
AND `+visibleChainTaskClause+`
ORDER BY due_date ASC, priority DESC
`, start, end)
@@ -88,7 +88,7 @@ func (s *Store) GetOverdueNativeTasks(before time.Time) ([]models.Task, error) {
chain_id, chain_position, chain_unlocked,
bucket_id, bucket_state, bucket_last_active_at
FROM native_tasks t
- WHERE completed = 0 AND due_date IS NOT NULL AND due_date < ?
+ WHERE completed = 0 AND abandoned = 0 AND due_date IS NOT NULL AND due_date < ?
AND `+visibleChainTaskClause+`
ORDER BY due_date ASC, priority DESC
`, before)
@@ -107,7 +107,7 @@ func (s *Store) GetUndatedNativeTasks() ([]models.Task, error) {
chain_id, chain_position, chain_unlocked,
bucket_id, bucket_state, bucket_last_active_at
FROM native_tasks t
- WHERE completed = 0 AND due_date IS NULL
+ WHERE completed = 0 AND abandoned = 0 AND due_date IS NULL
AND `+visibleChainTaskClause+`
AND bucket_state != 'dormant'
ORDER BY priority DESC, created_at ASC
@@ -493,6 +493,18 @@ func (s *Store) AdvanceDueRecurringTasks(now time.Time) (int, error) {
if err := s.CreateNextIteration(task); err != nil {
return 0, err
}
+ // The occurrence being superseded was never done, and now its
+ // replacement is here -- it's stale, not still owed. Left open it would
+ // sit in the list as a permanent overdue item and every skipped
+ // occurrence would add another. Not marked `completed`, since that would
+ // falsely credit work that never happened.
+ if !task.Completed {
+ if _, err := s.db.Exec(`
+ UPDATE native_tasks SET abandoned = 1, updated_at = ? WHERE id = ?
+ `, config.Now(), task.ID); err != nil {
+ return 0, err
+ }
+ }
}
return len(series), nil
}