Skip to content

feat(api): trending_genre notification for top 10 in a genre chart - #1071

Merged
dylanjeffers merged 1 commit into
mainfrom
feat/trending-genre-notification
Nov 12, 2026
Merged

dylanjeffers merged 1 commit into
mainfrom
feat/trending-genre-notification

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

Why

Michael approved idea #5 from the new-notification list (2026-11-11): tell artists when they chart in their genre, e.g. "[track] is #4 in Dubstep this week". It reaches many more artists than overall trending. His rule: only genres with at least 10 tracks on the chart that week.

What

  • TrendingGenreNotificationsJob (indexer, every minute).
  • Chart is the live week ranking in track_trending_scores (what /tracks/trending?genre= serves), version pnagD, genre-carrying rows only. Tracks that are deleted, unlisted or unavailable, or whose owner is deactivated, are dropped before ranking.
  • Rules: top 10 per genre, genre must have at least 10 tracks on the chart. Tracks that already got an overall trending notification that day are skipped so nobody gets two pushes for one track.
  • Timing: one snapshot per week on Friday (the day trending winners are picked), sent from 18:00 UTC for 24h. Stage sends any day, keyed by the latest Friday.
  • Once per week: scores recompute hourly, so the insert runs under an advisory lock and stops if any row for that Friday exists. group_id = trending_genre:<YYYY-MM-DD>:<track_id>, specifier = track_id.
  • Data: {track_id, genre, rank, week}.
  • New type rather than reusing trending with a genre: older app builds render trending as "Re-organize packages #4 on Trending", which would be wrong for a genre rank. It also doesn't depend on the trending reward challenge, which is being retired with $AUDIO rewards.
  • trending_genre added to the notifications types filter and swagger.

No migration.

Rollout

Merging only writes rows. The push stays off until push_trending_genre is set in Optimizely (pedalboard PR), and the tile is behind the trending_genre_notification flag (apps PR). Clients without the apps PR drop the row in the adapter.

Tests

go test ./jobs/ -run TrendingGenre and go test ./api/ -run Notification pass. Cases: ranks after dropping unlisted and deactivated tracks, the 10-track minimum (9-track genre gets nothing, exactly 10 qualifies), skipping tracks already notified for overall trending, ignoring month and genre-less rows, one snapshot per week even when scores move, the next Friday, send window edges and stage.

🤖 Generated with Claude Code

Every Friday, artists whose track is in the top 10 of its genre's weekly
trending chart get "[track] is #4 in Dubstep this week". Only genres with
at least 10 tracks on the chart count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanjeffers
dylanjeffers merged commit 0c9aa1c into main Nov 12, 2026
@dylanjeffers
dylanjeffers deleted the feat/trending-genre-notification branch November 12, 2026 00:35
dylanjeffers added a commit to AudiusProject/apps that referenced this pull request Nov 12, 2026
## Why

Michael approved the genre chart notification (2026-11-11). Every Friday
the api writes a `trending_genre` row for each track in the top 10 of
its genre's weekly chart, for genres with at least 10 tracks on the
chart (AudiusProject/api#1071). Pedalboard pushes it
(AudiusProject/pedalboard#112). This renders it.

## What

- **Adapter:** `trending_genre` maps to `NotificationType.TrendingGenre`
`{rank, genre, entityType: Track, entityId}`. Handled in the
pre-SDK-regen fallback like `weekly_artist_recap`. Rows with no genre or
a bad id are dropped.
- **Tiles:** web and mobile, "Charting in Dubstep" / "[track] is #4 in
Dubstep this week!". Web has the X share button, mobile has the share
card button. Both hidden while `trending_genre_notification` is off.
- **Push:** `TrendingGenre` opens the track and, with `shareCard`, the
stat card.
- **Share card:** new `genre` stat kind, headline `#4` / `In Dubstep`, X
text reuses the rank copy.
- **Flag** `trending_genre_notification`: on in dev, off in prod.

## Rollout

1. Merge api#1071 so rows start on the next Friday 18:00 UTC.
2. Ship this (web gate + mobile OTA), then turn on
`trending_genre_notification` in Optimizely.
3. Turn on `push_trending_genre` in `discovery_notification_mapping`.

While the flag is off, artists get an unread badge with no visible tile,
same as the recap.

## Tests

`vitest src/adapters/notification.test.ts` passes (maps the row, drops a
row with no genre). tsc on common, web and mobile shows nothing in the
changed files; the remaining errors come from my local SDK build being
older than main. Not checked in a running app yet.

🤖 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