From 9f311adb7dbac8b303da504b73174d6c036d8c17 Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Thu, 24 Sep 2026 12:10:51 -0700 Subject: [PATCH] fix(api): extend the 2026-39 Weekly Rotation send window to Saturday This week's fan-out ran against the stale listen-streak table; the plays fix (#1046) merged after the window closed Thursday 16:00 UTC. Keep sending for 2026-39 until Saturday 16:00 UTC. Other periods are unchanged. Co-Authored-By: Claude Opus 5.5 --- jobs/create_weekly_rotation_notifications.go | 13 ++++++++++++- jobs/create_weekly_rotation_notifications_test.go | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/jobs/create_weekly_rotation_notifications.go b/jobs/create_weekly_rotation_notifications.go index 54b48343..11d6bd0e 100644 --- a/jobs/create_weekly_rotation_notifications.go +++ b/jobs/create_weekly_rotation_notifications.go @@ -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) { @@ -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 { diff --git a/jobs/create_weekly_rotation_notifications_test.go b/jobs/create_weekly_rotation_notifications_test.go index 8c710f77..f8e8341e 100644 --- a/jobs/create_weekly_rotation_notifications_test.go +++ b/jobs/create_weekly_rotation_notifications_test.go @@ -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) +}