Skip to content

feat(api): weekly artist recap notification - #1070

Merged
dylanjeffers merged 1 commit into
mainfrom
feat/weekly-artist-recap
Nov 11, 2026
Merged

dylanjeffers merged 1 commit into
mainfrom
feat/weekly-artist-recap

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

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 (feat(api): tell artists how many Weekly Rotations featured their tracks #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 feat(api): tell artists how many Weekly Rotations featured their tracks #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 feat(api): tell artists how many Weekly Rotations featured their tracks #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

One weekly_artist_recap notification per artist on rollover Wednesday with
plays, new followers, top city, saves, and saves from Weekly Rotation
listeners for the week that just closed. Artists with no plays get nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanjeffers
dylanjeffers merged commit e4af3b0 into main Nov 11, 2026
@dylanjeffers
dylanjeffers deleted the feat/weekly-artist-recap branch November 11, 2026 21:06
dylanjeffers added a commit to AudiusProject/apps that referenced this pull request Nov 11, 2026
)

## Why

Michael picked the weekly artist recap (2026-11-11). The api writes one
`weekly_artist_recap` row per artist each Wednesday
(AudiusProject/api#1070), and pedalboard pushes it
(AudiusProject/pedalboard#111). Without this PR the adapter drops the
row.

## What

- `NotificationType.WeeklyArtistRecap` (also added to the push enum) and
`WeeklyArtistRecapNotification {playCount, followerCount, saveCount,
rotationSaveCount, topCity?, year, week}`. The adapter maps it in the
pre-regen fallback branch, the same way `weekly_rotation_featured` is
mapped, so no SDK regen is needed.
- Copy lives in `weeklyArtistRecapNotificationMessages` and matches the
push:
  - **Your Week on Audius**
- `1,240 plays, 18 new followers, top city Atlanta, 42 saves`. Zero
followers, zero saves and a missing city are left out.
- When some saves came from Weekly Rotation listeners, the tile adds: `5
saves came from Weekly Rotation listeners.`
- **Web tile** opens the Artist Dashboard. **Mobile tile** opens the
artist's own profile. A **push tap** on mobile opens the Notifications
tab, since the push has no entity.
- **Flag:** `weekly_artist_recap`, on in development and off by default
in production. Both tiles render nothing while it is off.

## Rollout

- Add `weekly_artist_recap` in Optimizely and turn it on when we want
the tile.
- The push is gated separately by `push_weekly_artist_recap` in
pedalboard.
- The first rows land Wednesday 18:00 UTC after the api merges. While
the flag is off, the server's unread count still includes the row, so an
artist can see a badge with no visible tile. Flip the flag before that
first Wednesday, or keep the api unmerged until then.

## Verification

- New vitest `packages/common/src/adapters/notification.test.ts` covers
the adapter mapping, a missing city, and the copy. It passes.
- `tsc` for common, web and mobile shows no errors in touched files. The
only errors are pre-existing ones from a stale local SDK build.
- eslint passes on all touched files.
- No device run: the tile can't 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 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