From 806658aa6093cd62dc6178811c31f2f72505e9e1 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 24 Nov 2026 07:24:58 -0500 Subject: [PATCH] feat(playlists): twelve Songs like mixes a day, drawn from a top-24 artist pool Six mixes stretched to oversized circles on a wide window; twelve fill the row at its normal tile size. The pool doubles with the count so the daily shuffle still rotates which artists get a mix. Co-Authored-By: Claude Opus 5.5 --- internal/db/dbq/system_playlists.sql.go | 6 +++--- internal/db/queries/system_playlists.sql | 6 +++--- internal/playlists/seed_selection_test.go | 8 ++++---- internal/playlists/system.go | 11 ++++++----- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/internal/db/dbq/system_playlists.sql.go b/internal/db/dbq/system_playlists.sql.go index a986855a..0f7e96d2 100644 --- a/internal/db/dbq/system_playlists.sql.go +++ b/internal/db/dbq/system_playlists.sql.go @@ -360,7 +360,7 @@ SELECT c.artist_id, FROM chosen c LEFT JOIN liked l ON l.artist_id = c.artist_id ORDER BY score DESC, c.artist_id - LIMIT 12 + LIMIT 24 ` type PickSeedArtistsRow struct { @@ -385,8 +385,8 @@ type PickSeedArtistsRow struct { // tiered pick-kind ladder and stamps the built tracks, so metrics // can compare mixes seeded from fresh vs stale engagement. // Score = unskipped-play count + 5 if user has liked the artist. The -// Go-side picker (pickSeedArtistsForDay) shuffles the 12 -// daily-deterministically and takes songsLikeSeedCount (6) so the mix +// Go-side picker (pickSeedArtistsForDay) shuffles the 24 +// daily-deterministically and takes songsLikeSeedCount (12) so the mix // set both rotates day-to-day and fills the dedicated Home row. func (q *Queries) PickSeedArtists(ctx context.Context, userID pgtype.UUID) ([]PickSeedArtistsRow, error) { rows, err := q.db.Query(ctx, pickSeedArtists, userID) diff --git a/internal/db/queries/system_playlists.sql b/internal/db/queries/system_playlists.sql index 09f71ddd..23260ba3 100644 --- a/internal/db/queries/system_playlists.sql +++ b/internal/db/queries/system_playlists.sql @@ -69,8 +69,8 @@ UPDATE system_playlist_runs SET in_flight = false WHERE in_flight = true; -- tiered pick-kind ladder and stamps the built tracks, so metrics -- can compare mixes seeded from fresh vs stale engagement. -- Score = unskipped-play count + 5 if user has liked the artist. The --- Go-side picker (pickSeedArtistsForDay) shuffles the 12 --- daily-deterministically and takes songsLikeSeedCount (6) so the mix +-- Go-side picker (pickSeedArtistsForDay) shuffles the 24 +-- daily-deterministically and takes songsLikeSeedCount (12) so the mix -- set both rotates day-to-day and fills the dedicated Home row. WITH liked AS ( SELECT gla.artist_id FROM general_likes_artists gla WHERE gla.user_id = $1 @@ -132,7 +132,7 @@ SELECT c.artist_id, FROM chosen c LEFT JOIN liked l ON l.artist_id = c.artist_id ORDER BY score DESC, c.artist_id - LIMIT 12; + LIMIT 24; -- name: PickTopPlayedTracksForUser :many -- For-You candidate seeds, tiered so For-You never silently vanishes: diff --git a/internal/playlists/seed_selection_test.go b/internal/playlists/seed_selection_test.go index 9a95509f..177cf1cc 100644 --- a/internal/playlists/seed_selection_test.go +++ b/internal/playlists/seed_selection_test.go @@ -159,7 +159,7 @@ func TestPickDailySeeds_EmptyPool(t *testing.T) { } } -// pickSeedArtistsForDay takes the user's top-12 candidate artists and +// pickSeedArtistsForDay takes the user's top-24 candidate artists and // returns songsLikeSeedCount of them via daily-deterministic shuffle. // Verifies the picker is deterministic within a day, varies across days, // and degrades gracefully when fewer than songsLikeSeedCount candidates @@ -186,7 +186,7 @@ func seedSetKey(seeds []pgtype.UUID) string { func TestPickSeedArtistsForDay_DeterministicWithinDay(t *testing.T) { u := pgtype.UUID{Bytes: [16]byte{1}, Valid: true} - pool := bigSeedPool(10) + pool := bigSeedPool(24) a := pickSeedArtistsForDay(pool, u, "2026-05-04") b := pickSeedArtistsForDay(pool, u, "2026-05-04") if len(a) != songsLikeSeedCount || len(b) != songsLikeSeedCount { @@ -201,9 +201,9 @@ func TestPickSeedArtistsForDay_DeterministicWithinDay(t *testing.T) { func TestPickSeedArtistsForDay_VariesAcrossDays(t *testing.T) { u := pgtype.UUID{Bytes: [16]byte{1}, Valid: true} - pool := bigSeedPool(10) + pool := bigSeedPool(24) // Collect the seed set (order-independent) across many dates. With - // C(10, songsLikeSeedCount) combinations, 30 dates yield >=2 distinct sets. + // C(24, songsLikeSeedCount) combinations, 30 dates yield >=2 distinct sets. seen := map[string]bool{} for i := 1; i <= 30; i++ { got := pickSeedArtistsForDay(pool, u, "2026-05-"+twoDigits(i)) diff --git a/internal/playlists/system.go b/internal/playlists/system.go index 5567da7b..d91eb1a5 100644 --- a/internal/playlists/system.go +++ b/internal/playlists/system.go @@ -35,7 +35,7 @@ type seedArtistRow struct { } // pickSeedArtistsFromRows projects sqlc rows into the seed list. The -// SQL already orders by score DESC + artist_id and LIMIT 12, so this is +// SQL already orders by score DESC + artist_id and LIMIT 24, so this is // just a column projection — but pulling it into a function keeps the // call-site readable and makes the post-fetch path testable without // a database. @@ -106,10 +106,11 @@ func pickDailySeeds(pool []pgtype.UUID, userID pgtype.UUID, dateStr string, n in } // songsLikeSeedCount is how many "Songs like {artist}" mixes to build -// each day, enough to fill Songs-like's own Home row. Drawn from -// PickSeedArtists' deeper top-12 pool via a daily-deterministic shuffle so -// the set still rotates day to day rather than pinning the same six artists. -const songsLikeSeedCount = 6 +// each day, enough to fill Songs-like's own Home row at its normal tile +// size on a wide window. Drawn from PickSeedArtists' deeper top-24 pool via +// a daily-deterministic shuffle so the set still rotates day to day rather +// than pinning the same twelve artists. +const songsLikeSeedCount = 12 // pickSeedArtistsForDay picks up to songsLikeSeedCount seed artists for // the Songs-like mixes; For-You uses pickDailySeeds directly with