Skip to content

feat(api): tell artists how many Weekly Rotations featured their tracks - #1069

Merged
dylanjeffers merged 1 commit into
mainfrom
feat/weekly-rotation-featured-notification
Nov 11, 2026
Merged

dylanjeffers merged 1 commit into
mainfrom
feat/weekly-rotation-featured-notification

Conversation

@dylanjeffers

@dylanjeffers dylanjeffers commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Why

Product spec (Michael Cullen): when Weekly Rotation refreshes on Wednesday, tell each artist how many listeners' rotations included their tracks. One notification per artist per week, in-app and push, sent on the Wednesday refresh rather than per inclusion.

What

  • WeeklyRotationFeaturedNotificationsJob (indexer, every 30s). Writes one weekly_rotation_featured row per artist per period.
    • Timing. Mixes are stored lazily, on each listener's first request of a period (weekly_rotation_mixes), so counts only become final when the period ends. The job runs on rollover Wednesday from 18:00 UTC for 24h and reports the period that just closed (the 2026-38 rollover reports 2026-37). That is two hours after the listener "Your Weekly Rotation Is Ready" fan-out, so the two don't overlap. Stage sends all week, same as the listener job.
    • What counts. A track counts when it's in the first 30 slots of a stored mix (the slots clients show) and is still live (is_delete / is_unlisted / is_available). Artists who are deactivated or unavailable are skipped. rotation_count = distinct listeners whose mix had any of the artist's tracks.
    • Data: {year, week, track_id, track_count, rotation_count}. track_id is the most-featured track, and the only one when track_count = 1. It's mined into related.tracks like other track_id notifications.
    • Idempotency and pacing follow WeeklyRotationNotificationsJob: group_id = weekly_rotation_featured:<YYYY-WW>:<artist_id>, specifier = artist_id, uq_notification plus NOT EXISTS, and an in-memory owner_id cursor with batches of 1000. A short batch marks the period drained, so later ticks skip the aggregate.
  • weeklyRotationSeenSize becomes weeklyrotation.ShownSize, so the endpoint's repeat suppression and this job agree on what "in the rotation" means.
  • weekly_rotation_featured is accepted by the notifications types filter and documented in swagger.

No migration. The aggregate scans weekly_rotation_mixes for one period_start, which is one row per listener who opened their mix that week. Once drained, it runs at most once per replica per period.

Rollout

Merging this only writes rows. The push stays off until push_weekly_rotation_featured is added to discovery_notification_mapping in Optimizely and set true (pedalboard PR: feat/weekly-rotation-featured-notification). Clients that predate the apps PR drop the row in the adapter.

Tests

go test ./jobs/ ./weeklyrotation/ ./api/ -run 'WeeklyRotation|Period|Notification' pass. New cases:

  • FanOut: single-track and multi-track counts, plus the top-track pick. Excluded: deactivated owners, deleted tracks, slot 31, the in-progress period. Also checks idempotency across reruns and restarts, and that the next rollover reports the next period.
  • SendWindow edges, stage override, and pacing/drain.

🤖 Generated with Claude Code

New WeeklyRotationFeaturedNotificationsJob writes one
weekly_rotation_featured notification per artist per period. It runs on
rollover Wednesday (from 18:00 UTC, for 24h) and reports the period that
just closed, because mixes are stored lazily on each listener's first
request and a period's counts are only final once it ends.

A track counts if it sat in the first weeklyrotation.ShownSize (30) slots
of a stored mix and is still live; rotation_count is the number of
distinct listeners whose mix included any of the artist's tracks. Data:
{year, week, track_id (most-featured), track_count, rotation_count}.

ShownSize moves into the weeklyrotation package so the endpoint's repeat
suppression and the job agree on what "in the rotation" means.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dylanjeffers added a commit to AudiusProject/apps that referenced this pull request Nov 11, 2026
…#14758)

## Why

Product spec (Michael Cullen): tell artists every Wednesday how many
listeners' Weekly Rotations featured their tracks. The api writes one
`weekly_rotation_featured` row per artist per week
(AudiusProject/api#1069) and pedalboard pushes it
(AudiusProject/pedalboard#110). Without this PR the adapter drops the
row, and tapping the push does nothing.

## What

- `NotificationType.WeeklyRotationFeatured` (also added to the push
enum). Common also gets `WeeklyRotationFeaturedNotification {entityId
(top track), trackCount, rotationCount, year, week}` and the push
payload type. The adapter maps `weekly_rotation_featured` in the
pre-regen fallback branch, so no SDK regen is needed.
- Copy lives in `weeklyRotationFeaturedNotificationMessages`:
- One track: **Your \<track link\> was featured in N Weekly Rotation(s)
last week**
- Several tracks: **Your tracks were featured in N Weekly Rotations last
week**
- **Web tile:** one track links to the track; several link to the
artist's profile.
- **Mobile tile:** same behavior, plus a `useNotificationNavigation`
handler that covers both the tile and the push (`entityType: 'Track' |
'User'`). For the multi-track tile, it reads the owner from the track
cache that `useNotificationEntity` already filled. The Event handler
uses the same pattern.
- Not behind the `weekly_rotation` flag. The tile opens a track or
profile, not the rotation page, and the flag now defaults on.

## Timing note

The counts are for the rotation period that **just closed**. Mixes are
computed when each listener first opens theirs, so a period's totals are
only final at the next Wednesday rollover. The copy says "last week"
(product call, Michael Cullen).

## Verification

- `tsc` for common, web and mobile: no errors in touched files. The only
errors are pre-existing ones from local build outputs.
- eslint on all touched files.
- No device run: neither tile can be reached locally without a row from
the api job.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@dylanjeffers
dylanjeffers merged commit 16642d2 into main Nov 11, 2026
@dylanjeffers
dylanjeffers deleted the feat/weekly-rotation-featured-notification branch November 11, 2026 18:59
dylanjeffers added a commit that referenced this pull request Nov 11, 2026
## Why

Michael picked the weekly artist recap from the new-notification list
(2026-11-11). Each artist gets one note on Wednesday about the week that
just closed, e.g. "Your week: 1,240 plays, 18 new followers, top city
Atlanta, 42 saves."

## What

- **`WeeklyArtistRecapNotificationsJob`** (indexer, every 30s), modeled
on `WeeklyRotationFeaturedNotificationsJob` (#1069).
- **Timing.** The week is the Weekly Rotation period (Wednesday 00:00
UTC to Wednesday). Sends start rollover Wednesday at **18:00 UTC for
24h** and report the period that just closed. Stage sends all week.
- **Data:** `{year, week, play_count, follower_count, save_count,
rotation_save_count, top_city?}`.
- `play_count`: rows in `plays` for the artist's tracks that week,
excluding the artist's own plays.
  - `follower_count`: follows created that week and still current.
  - `save_count`: track saves created that week and still current.
- `rotation_save_count`: those saves where the saver's mix for that
period had the track in the first `weeklyrotation.ShownSize` slots.
- `top_city`: most common non-empty `plays.city`, ties by name. Left out
when no play had a city.
- **Who gets it.** Artists with at least one play from someone else that
week, and not deactivated or unavailable.
- **Idempotency** is the same as #1069: `group_id =
weekly_artist_recap:<YYYY-WW>:<artist_id>`, `specifier = artist_id`,
`uq_notification` plus `NOT EXISTS`.
- **Pacing.** This is the one change from #1069. A week of `plays` is
too big to scan on every tick, so each replica counts once per period
(`ix_plays_created_at` range scan), keeps the sorted rows in memory, and
inserts 1000 per tick past an `owner_id` cursor.
- `weekly_artist_recap` is added to the notifications `types` filter and
to swagger.

No migration.

## Rollout

Merging this only writes rows. The push stays off until
`push_weekly_artist_recap` is added to `discovery_notification_mapping`
in Optimizely and set to true (pedalboard PR
`feat/weekly-artist-recap`). Clients that predate the apps PR drop the
row in the adapter.

The weekly count query has not been timed against prod data. Check the
"Loaded weekly_artist_recap counts" log line (it includes the duration)
on the first Wednesday.

## Tests

`go test ./jobs/ -run 'WeeklyArtistRecap|WeeklyRotationFeatured'` and
`go test ./api/ -run Notification` pass. Cases:
- **FanOut:** exact counts and top city. Excluded: plays outside the
week, self plays, deleted follows, follows before the week, a save past
slot 30, a save matched to the wrong period's mix, deactivated artists,
and artists with no plays. Also covers an artist with no city,
idempotency across reruns and restarts, and the next rollover.
- **SendWindow edges**, **stage override**, **pacing/drain**.

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

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
dylanjeffers added a commit that referenced this pull request Nov 12, 2026
…hem (#1073)

Notifications stopped loading on web and mobile this afternoon.

The generated SDK's `NotificationFromJSONTyped` throws on any type it
doesn't know, so the whole response is rejected. Today's
`weekly_rotation_featured` (#1069), `weekly_artist_recap` (#1070) and
`trending_genre` (#1071) aren't in the SDK on any shipped client (or on
apps main), and clients don't pass `types`, so any user with one of
those rows got an empty list.

These three types are now returned (and counted in `unread_count`) only
when the caller includes them in `types`. Everything else is unchanged.

The client still needs a follow-up: regenerate the SDK and request these
types explicitly, and stop one unknown type from failing the whole page.

Test: `TestV1Notifications_OptInTypesHiddenUnlessRequested` (fails
without the fix).

🤖 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