Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion jobs/create_weekly_rotation_notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ func (j *WeeklyRotationNotificationsJob) Run(ctx context.Context) {
}
}

// weeklyRotationWindowExtensions lengthens the send window for specific
// periods. 2026-39 went out with a stale recipient list; the fix merged after
// its window closed. Remove once that period has passed.
var weeklyRotationWindowExtensions = map[string]time.Duration{
"2026-39": 48 * time.Hour,
}

// sendWindow returns the instants between which the period containing
// `now` is announced.
func (j *WeeklyRotationNotificationsJob) sendWindow(now time.Time) (start, end time.Time) {
Expand All @@ -96,7 +103,11 @@ func (j *WeeklyRotationNotificationsJob) sendWindow(now time.Time) (start, end t
return periodStart, periodStart.AddDate(0, 0, 7)
}
start = periodStart.Add(weeklyRotationSendHourUTC * time.Hour)
return start, start.Add(weeklyRotationSendWindow)
window := weeklyRotationSendWindow
if extra, ok := weeklyRotationWindowExtensions[weeklyrotation.PeriodKey(year, week)]; ok {
window += extra
}
return start, start.Add(window)
}

func (j *WeeklyRotationNotificationsJob) run(ctx context.Context) error {
Expand Down
14 changes: 14 additions & 0 deletions jobs/create_weekly_rotation_notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,17 @@ func TestWeeklyRotationNotifications_Pacing(t *testing.T) {
require.NoError(t, job.run(ctx))
assert.Equal(t, 2, countNotifications(t, ctx, pool, "weekly_rotation"))
}

func TestWeeklyRotationNotifications_WindowExtension(t *testing.T) {
job := NewWeeklyRotationNotificationsJob(newTestConfig(), nil)

// 2026-09-23 is the Wednesday that opens period 2026-39.
start, end := job.sendWindow(time.Date(2026, time.September, 24, 19, 0, 0, 0, time.UTC))
assert.Equal(t, time.Date(2026, time.September, 23, 16, 0, 0, 0, time.UTC), start)
assert.Equal(t, time.Date(2026, time.September, 26, 16, 0, 0, 0, time.UTC), end)

// Other periods keep the normal window.
start, end = job.sendWindow(weeklyRotationSendInstant)
assert.Equal(t, weeklyRotationSendInstant, start)
assert.Equal(t, weeklyRotationSendInstant.Add(weeklyRotationSendWindow), end)
}
Loading