package scheduler import ( "context" "log" "time" "task-dashboard/internal/config" "task-dashboard/internal/store" ) // RunRecurrenceCheck ticks every interval, calling AdvanceDueRecurringTasks // until ctx is cancelled. Errors are logged, not fatal -- one bad tick // shouldn't kill the loop; the next tick tries again. func RunRecurrenceCheck(ctx context.Context, s *store.Store, interval time.Duration) { ticker := time.NewTicker(interval) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: n, err := s.AdvanceDueRecurringTasks(config.Now()) if err != nil { log.Printf("ERROR [RecurrenceCheck]: %v", err) continue } if n > 0 { log.Printf("RecurrenceCheck: created %d next iteration(s)", n) } } } }