fix(alarms): Kanban moves no longer re-arm due alarms of open tasks
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 2m0s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 2m0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
21dd5e504e
commit
1b35bb3de4
6 files changed
+54
-7
No files matched your search
@@ -139,6 +139,44 @@ func TestAlarmResetsOnNewDueDateOrReopen(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A Kanban move sends every task of the touched columns: only a task that goes from done back to open
|
||||
// may get its due alarm again, the others must not be notified a second time
|
||||
func TestKanbanMoveKeepsSentAlarms(t *testing.T) {
|
||||
store, err := NewStore(filepath.Join(t.TempDir(), "kanban-alarm.db"))
|
||||
if err != nil {
|
||||
t.Fatalf("NewStore: %v", err)
|
||||
}
|
||||
defer store.Close()
|
||||
u, _ := store.CreateUser("anna@example.com", "hash", "Anna", "member")
|
||||
tl, _ := store.CreateTaskList(u.ID, "", "", "Haushalt", "🏠", "")
|
||||
task, _ := store.CreateThoughtWithDetails(u.ID, "Heizung entlüften", "normal", "manual", "2026-10-31 09:00", tl.ID, "todo", "")
|
||||
_, _ = store.UpdateThoughtTriage(u.ID, task.ID, "keep", "task", "", "", tl.ID)
|
||||
sent := func() bool {
|
||||
th, _ := store.GetThoughtByID(u.ID, task.ID)
|
||||
return th.AlarmSent
|
||||
}
|
||||
move := func(status string) {
|
||||
if err := store.ReorderTasks(tl.ID, []domain.ThoughtReorderItem{{ID: task.ID, SortOrder: 0, KanbanStatus: &status}}); err != nil {
|
||||
t.Fatalf("ReorderTasks: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
_ = store.MarkTaskAlarmSent(task.ID)
|
||||
move("in_progress")
|
||||
move("todo")
|
||||
if !sent() {
|
||||
t.Errorf("moving an open task between columns must not re-arm its alarm")
|
||||
}
|
||||
move("done")
|
||||
if !sent() {
|
||||
t.Errorf("completing keeps the flag")
|
||||
}
|
||||
move("todo")
|
||||
if sent() {
|
||||
t.Errorf("reopening via the board must re-arm the alarm")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAlarmGivesUpAfterThreeFailedRuns(t *testing.T) {
|
||||
store, err := NewStore(filepath.Join(t.TempDir(), "alarmfail.db"))
|
||||
if err != nil {
|
||||
|
||||
@@ -243,10 +243,13 @@ func (s *Store) ReorderTasks(taskListID string, items []domain.ThoughtReorderIte
|
||||
completed = append(completed, it.ID)
|
||||
}
|
||||
}
|
||||
// Only a reopened task (done -> open) gets its due alarm again. A Kanban move sends every task
|
||||
// of the touched columns, so resetting all open ones re-sent "due today" for each of them.
|
||||
// (is_completed in the CASE is still the value before this UPDATE.)
|
||||
_, err = tx.Exec(
|
||||
`UPDATE thoughts SET sort_order = ?, kanban_status = ?, is_completed = ?,
|
||||
alarm_sent = CASE WHEN ? = 0 THEN 0 ELSE alarm_sent END,
|
||||
alarm_failures = CASE WHEN ? = 0 THEN 0 ELSE alarm_failures END WHERE id = ?`,
|
||||
alarm_sent = CASE WHEN ? = 0 AND is_completed = 1 THEN 0 ELSE alarm_sent END,
|
||||
alarm_failures = CASE WHEN ? = 0 AND is_completed = 1 THEN 0 ELSE alarm_failures END WHERE id = ?`,
|
||||
it.SortOrder, *it.KanbanStatus, isCompleted, isCompleted, isCompleted, it.ID,
|
||||
)
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user