Skip to content

Re-organize packages - #4

Merged
raymondjacobson merged 5 commits into
mainfrom
reorg
Apr 3, 2025
Merged

raymondjacobson merged 5 commits into
mainfrom
reorg

Conversation

@stereosteve

Copy link
Copy Markdown
Contributor
  • move top level queries to api/dbv1 package and move sql files to api/dbv1/queries directory.
    These queries only exist to service api v1 endpoints, so make it clear in package hierarchy.
  • move tests out into dedicated files.
  • helper to unmarshal server response into struct for further testing.

These queries only exist to service api v1 endpoints, so make it clear in package heirarchy.
@raymondjacobson
raymondjacobson merged commit 66b5799 into main Apr 3, 2025
@stereosteve
stereosteve deleted the reorg branch April 14, 2025 14:49
dylanjeffers added a commit that referenced this pull request Nov 12, 2026
…1071)

## 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 "#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](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.

2 participants