feat: genre mixes pick specific genres that don't share songs (#6933)
release / go (push) Successful in 2m0s
release / web (push) Successful in 1m33s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 5m11s
release / android (push) Successful in 4m14s
release / Build signed APK (push) Successful in 4m38s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 29s
release / Verify release artifacts (tag releases only) (push) Skipped

The shelf had four mixes built largely from the same lo-fi beats: about
1,250 tracks carry Hip Hop, Lo-Fi, Instrumental, Downtempo and four more
tags at once, and the near-duplicate guard compared artists, not songs, so
each tag passed as its own channel.

Genre selection now works on songs:
- ListGenreMixCandidates returns each genre's track ids instead of its
  artist ids.
- A broad genre, one whose songs mostly also carry clearly narrower
  candidates (Rock over Pop Punk and Ska Punk), is considered after the
  specific genres of its tier.
- A genre is kept only when at least half its songs are not already in a
  kept genre.
- Each mix leaves out songs tagged with a genre kept before it
  (ListGenreMixTracks exclude_genres), so a song is in one mix at most.

The tiers, the minimum shelf and the minimum mix length are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 14:55:19 -05:00
co-authored by Claude Opus 5.5
parent 14debe2ea9
commit dabe1e052d
5 changed files with 262 additions and 80 deletions
+36 -2
View File
@@ -64,8 +64,8 @@ func TestListGenreMixCandidates_TiersAndSizeFloor(t *testing.T) {
if _, mine := want[r.Label]; mine {
order = append(order, r.Label)
}
if r.Label == "Shoegaze" && len(r.ArtistIds) != 6 {
t.Errorf("Shoegaze artist_ids = %d, want 6", len(r.ArtistIds))
if r.Label == "Shoegaze" && len(r.TrackIds) != 30 {
t.Errorf("Shoegaze track_ids = %d, want 30", len(r.TrackIds))
}
}
for label, w := range want {
@@ -81,6 +81,40 @@ func TestListGenreMixCandidates_TiersAndSizeFloor(t *testing.T) {
}
}
// TestListGenreMixTracks_LeavesOutSongsOfGenresAlreadyPicked: a track that
// also carries an excluded genre (matched case-insensitively) belongs to that
// genre's mix and is left out of this one.
func TestListGenreMixTracks_LeavesOutSongsOfGenresAlreadyPicked(t *testing.T) {
pool := newPool(t)
ctx := context.Background()
u := seedUser(t, pool, "gmixexcl")
punk := seedGenre(t, pool, "Ska Punk", 4, 5)
shared := punk[:5]
for _, tr := range shared {
setGenre(t, pool, tr.ID, "Ska Punk; Pop Punk")
}
rows, err := dbq.New(pool).ListGenreMixTracks(ctx, dbq.ListGenreMixTracksParams{
UserID: u.ID, DateSeed: "2026-11-07", GenreKey: "ska punk", ExcludeGenres: []string{"pop punk"},
})
if err != nil {
t.Fatalf("list tracks: %v", err)
}
if len(rows) != len(punk)-len(shared) {
t.Fatalf("rows = %d, want %d (the Ska Punk tracks not also Pop Punk)", len(rows), len(punk)-len(shared))
}
got := map[pgtype.UUID]bool{}
for _, r := range rows {
got[r.ID] = true
}
for _, tr := range shared {
if got[tr.ID] {
t.Fatal("a track also tagged Pop Punk was offered after Pop Punk was excluded")
}
}
}
// TestListGenreMixTracks_SplitsFamiliarAndDropsRejectedTracks: played and
// liked tracks come back familiar, the rest unheard; a track skipped more
// often than played through is left out, while a favourite with stray skips