feat: add daily cron to apply scheduled default hours changes
Add ApplyScheduledDefaultHours which checks default_hours_scheduled_changes at midnight, bulk-updates working_hours with staged values, and inserts an admin_notification. Register as the 'apply-default-hours' job in the scheduler (daily at 00:05).
This commit is contained in:
@@ -133,6 +133,16 @@ func RegisterAll(s *Scheduler) {
|
||||
Handler: scheduling.CleanupOldNameHistory,
|
||||
})
|
||||
|
||||
// === STAGED HOURS CHANGE ===
|
||||
|
||||
s.Register(Job{
|
||||
Name: "apply-default-hours",
|
||||
Schedule: "5 0 * * *", // Daily at 00:05 — after midnight to avoid race
|
||||
Timeout: 30 * time.Second,
|
||||
Concurrency: 1,
|
||||
Handler: scheduling.ApplyScheduledDefaultHours,
|
||||
})
|
||||
|
||||
// === BUSINESS LOGIC JOBS ===
|
||||
|
||||
s.Register(Job{
|
||||
|
||||
@@ -407,17 +407,14 @@ func TestColoredRows_Reset(t *testing.T) {
|
||||
// RegisterAll Tests
|
||||
// ============================================================
|
||||
|
||||
// TestRegisterAll_RegistersExpectedJobs verifies RegisterAll registers exactly 19 jobs
|
||||
// with all required fields populated (non-empty Name, non-empty Schedule, non-nil
|
||||
// Handler, positive Timeout).
|
||||
func TestRegisterAll_RegistersExpectedJobs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
s := New()
|
||||
RegisterAll(s)
|
||||
|
||||
if got := len(s.registry); got != 19 {
|
||||
t.Fatalf("RegisterAll() registered %d jobs, want 19", got)
|
||||
if got := len(s.registry); got != 20 {
|
||||
t.Fatalf("RegisterAll() registered %d jobs, want 20", got)
|
||||
}
|
||||
|
||||
registered := make(map[string]Job, len(s.registry))
|
||||
@@ -490,6 +487,7 @@ func expectedJobNames() map[string]bool {
|
||||
"transition-discount-campaigns": true,
|
||||
"cleanup-verification-codes": true,
|
||||
"cleanup-refresh-tokens": true,
|
||||
"apply-default-hours": true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user