Skip to content

fix(api): pick Weekly Rotation push recipients from plays - #1046

Merged
dylanjeffers merged 1 commit into
mainfrom
fix/weekly-rotation-push-recipients
Sep 24, 2026
Merged

dylanjeffers merged 1 commit into
mainfrom
fix/weekly-rotation-push-recipients

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

The weekly_rotation job chose recipients from challenge_listen_streak.last_listen_date. The only writer of that table is ListenStreakProcessor, which returns early unless challenge e is active, and prod reports e as active: false (/v1/challenges/e/info). So the table is stale and the Wednesday fan-out was reaching almost nobody.

  • Recipients are now live users with a play in the last 30 days. The EXISTS uses date_trunc('hour', created_at) so it's a range scan on ix_plays_user_hour.
  • Shortened the job's doc comment and removed the claim that it picks up listeners who become eligible after the cursor passes them (the cursor only moves forward).

Not verified against prod data: I couldn't count stale rows (Metabase auth failed, kubectl needs a fresh gcloud login). Worth a quick select count(*) from challenge_listen_streak where last_listen_date > now() - interval '30 days' vs. the Sep 16 weekly_rotation notification count.

Tests: go test ./jobs/ -run TestWeeklyRotationNotifications passes.

🤖 Generated with Claude Code

challenge_listen_streak is only written by ListenStreakProcessor, which is a
no-op while challenge `e` is inactive (it is in prod), so the table is stale
and the weekly_rotation job was selecting almost no one. Use a recent play
instead, via ix_plays_user_hour.

Also trims the job's doc comment and drops the claim that the send window
picks up listeners who become eligible after the cursor passes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanjeffers
dylanjeffers merged commit 7967577 into main Sep 24, 2026
2 checks passed
@dylanjeffers
dylanjeffers deleted the fix/weekly-rotation-push-recipients branch September 24, 2026 19:01
dylanjeffers added a commit that referenced this pull request Sep 24, 2026
This week's push used the stale `challenge_listen_streak` recipients.
#1046 fixed that, but it merged at 19:00 UTC Thursday, after the 2026-39
window closed (Thu 16:00 UTC).

- Extends the send window for period `2026-39` only, by 48h: sends now
run until Sat 2026-09-26 16:00 UTC. Other periods keep the 24h window.
- Idempotent as before: anyone already notified for 2026-39 is skipped
via the group_id.
- The override map can be removed after this weekend.

Tests: `go test ./jobs/ -run TestWeeklyRotationNotifications` passes,
including a new window-extension test.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant