feat: Your genres leads with the genres you play most, not A to Z
release / web (push) Successful in 1m8s
release / go (push) Successful in 1m40s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 3m43s
release / android (push) Successful in 4m21s
release / Build signed APK (push) Successful in 4m55s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 22s
release / Verify release artifacts (tag releases only) (push) Skipped

The genre mix builder already ranks genres by how much you listen to
them (taste profile, then plays and likes, then library size), but the
rank was lost when the mixes were stored and both apps sorted the shelf
by name. Each playlist now has a shelf_rank (migration 0107), which the
genre builder fills 1..n in that listening order, even where it picked a
narrower genre before a broader one. The list and detail endpoints carry
it, and the web and Android Home sort the genre shelf by it, unranked
playlists after by name. Android's playlist cache gains the column
(Room v14).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 18:10:08 -05:00
co-authored by Claude Opus 5.5
parent 7cc14da1a7
commit 104f9fd141
25 changed files with 220 additions and 41 deletions
+1
View File
@@ -448,6 +448,7 @@ type Playlist struct {
Kind string
SystemVariant *string
SeedArtistID pgtype.UUID
ShelfRank int32
}
type PlaylistTrack struct {
+12 -5
View File
@@ -59,7 +59,7 @@ func (q *Queries) AppendPlaylistTrack(ctx context.Context, arg AppendPlaylistTra
const createPlaylist = `-- name: CreatePlaylist :one
INSERT INTO playlists (user_id, name, description, is_public)
VALUES ($1, $2, $3, $4)
RETURNING id, user_id, name, description, is_public, cover_path, track_count, duration_sec, created_at, updated_at, kind, system_variant, seed_artist_id
RETURNING id, user_id, name, description, is_public, cover_path, track_count, duration_sec, created_at, updated_at, kind, system_variant, seed_artist_id, shelf_rank
`
type CreatePlaylistParams struct {
@@ -91,6 +91,7 @@ func (q *Queries) CreatePlaylist(ctx context.Context, arg CreatePlaylistParams)
&i.Kind,
&i.SystemVariant,
&i.SeedArtistID,
&i.ShelfRank,
)
return i, err
}
@@ -132,7 +133,7 @@ func (q *Queries) DeletePlaylistTrack(ctx context.Context, arg DeletePlaylistTra
}
const getPlaylist = `-- name: GetPlaylist :one
SELECT p.id, p.user_id, p.name, p.description, p.is_public, p.cover_path, p.track_count, p.duration_sec, p.created_at, p.updated_at, p.kind, p.system_variant, p.seed_artist_id, u.username AS owner_username
SELECT p.id, p.user_id, p.name, p.description, p.is_public, p.cover_path, p.track_count, p.duration_sec, p.created_at, p.updated_at, p.kind, p.system_variant, p.seed_artist_id, p.shelf_rank, u.username AS owner_username
FROM playlists p
JOIN users u ON u.id = p.user_id
WHERE p.id = $1
@@ -152,6 +153,7 @@ type GetPlaylistRow struct {
Kind string
SystemVariant *string
SeedArtistID pgtype.UUID
ShelfRank int32
OwnerUsername string
}
@@ -172,13 +174,14 @@ func (q *Queries) GetPlaylist(ctx context.Context, id pgtype.UUID) (GetPlaylistR
&i.Kind,
&i.SystemVariant,
&i.SeedArtistID,
&i.ShelfRank,
&i.OwnerUsername,
)
return i, err
}
const getPlaylistsByIDs = `-- name: GetPlaylistsByIDs :many
SELECT id, user_id, name, description, is_public, cover_path, track_count, duration_sec, created_at, updated_at, kind, system_variant, seed_artist_id FROM playlists WHERE id = ANY($1::uuid[])
SELECT id, user_id, name, description, is_public, cover_path, track_count, duration_sec, created_at, updated_at, kind, system_variant, seed_artist_id, shelf_rank FROM playlists WHERE id = ANY($1::uuid[])
`
// Batched lookup used by /api/library/sync to hydrate upsert payloads
@@ -206,6 +209,7 @@ func (q *Queries) GetPlaylistsByIDs(ctx context.Context, dollar_1 []pgtype.UUID)
&i.Kind,
&i.SystemVariant,
&i.SeedArtistID,
&i.ShelfRank,
); err != nil {
return nil, err
}
@@ -380,7 +384,7 @@ func (q *Queries) ListPlaylistTracks(ctx context.Context, playlistID pgtype.UUID
}
const listPlaylistsForUser = `-- name: ListPlaylistsForUser :many
SELECT p.id, p.user_id, p.name, p.description, p.is_public, p.cover_path, p.track_count, p.duration_sec, p.created_at, p.updated_at, p.kind, p.system_variant, p.seed_artist_id, u.username AS owner_username
SELECT p.id, p.user_id, p.name, p.description, p.is_public, p.cover_path, p.track_count, p.duration_sec, p.created_at, p.updated_at, p.kind, p.system_variant, p.seed_artist_id, p.shelf_rank, u.username AS owner_username
FROM playlists p
JOIN users u ON u.id = p.user_id
WHERE p.user_id = $1 OR p.is_public = true
@@ -401,6 +405,7 @@ type ListPlaylistsForUserRow struct {
Kind string
SystemVariant *string
SeedArtistID pgtype.UUID
ShelfRank int32
OwnerUsername string
}
@@ -429,6 +434,7 @@ func (q *Queries) ListPlaylistsForUser(ctx context.Context, userID pgtype.UUID)
&i.Kind,
&i.SystemVariant,
&i.SeedArtistID,
&i.ShelfRank,
&i.OwnerUsername,
); err != nil {
return nil, err
@@ -480,7 +486,7 @@ SET
is_public = CASE WHEN $5::boolean THEN $6::boolean ELSE is_public END,
updated_at = now()
WHERE id = $7
RETURNING id, user_id, name, description, is_public, cover_path, track_count, duration_sec, created_at, updated_at, kind, system_variant, seed_artist_id
RETURNING id, user_id, name, description, is_public, cover_path, track_count, duration_sec, created_at, updated_at, kind, system_variant, seed_artist_id, shelf_rank
`
type UpdatePlaylistParams struct {
@@ -521,6 +527,7 @@ func (q *Queries) UpdatePlaylist(ctx context.Context, arg UpdatePlaylistParams)
&i.Kind,
&i.SystemVariant,
&i.SeedArtistID,
&i.ShelfRank,
)
return i, err
}
+8 -4
View File
@@ -26,9 +26,9 @@ func (q *Queries) ClearStaleSystemPlaylistInFlight(ctx context.Context) error {
const createSystemPlaylist = `-- name: CreateSystemPlaylist :one
INSERT INTO playlists (
user_id, name, description, is_public,
kind, system_variant, seed_artist_id, cover_path
) VALUES ($1, $2, $6, false, 'system', $3, $4, $5)
RETURNING id, user_id, name, description, is_public, cover_path, track_count, duration_sec, created_at, updated_at, kind, system_variant, seed_artist_id
kind, system_variant, seed_artist_id, cover_path, shelf_rank
) VALUES ($1, $2, $6, false, 'system', $3, $4, $5, $7)
RETURNING id, user_id, name, description, is_public, cover_path, track_count, duration_sec, created_at, updated_at, kind, system_variant, seed_artist_id, shelf_rank
`
type CreateSystemPlaylistParams struct {
@@ -38,11 +38,13 @@ type CreateSystemPlaylistParams struct {
SeedArtistID pgtype.UUID
CoverPath *string
Description string
ShelfRank int32
}
// Inserts a system-generated playlist. Used by BuildSystemPlaylists.
// For 'for_you' variant, pass seed_artist_id as NULL (zero-value pgtype.UUID
// with Valid=false).
// with Valid=false). shelf_rank is the mix's place on its Home shelf, 1
// first, or 0 for kinds the clients order themselves.
func (q *Queries) CreateSystemPlaylist(ctx context.Context, arg CreateSystemPlaylistParams) (Playlist, error) {
row := q.db.QueryRow(ctx, createSystemPlaylist,
arg.UserID,
@@ -51,6 +53,7 @@ func (q *Queries) CreateSystemPlaylist(ctx context.Context, arg CreateSystemPlay
arg.SeedArtistID,
arg.CoverPath,
arg.Description,
arg.ShelfRank,
)
var i Playlist
err := row.Scan(
@@ -67,6 +70,7 @@ func (q *Queries) CreateSystemPlaylist(ctx context.Context, arg CreateSystemPlay
&i.Kind,
&i.SystemVariant,
&i.SeedArtistID,
&i.ShelfRank,
)
return i, err
}
@@ -0,0 +1 @@
ALTER TABLE playlists DROP COLUMN shelf_rank;
@@ -0,0 +1,6 @@
-- Where a system mix sits on its Home shelf, 1 first. The genre mix builder
-- numbers its mixes by how much the user listens to each genre, so the
-- "Your genres" shelf leads with their main genres rather than reading
-- A to Z. 0 means unranked: every other playlist, which clients order their
-- own way.
ALTER TABLE playlists ADD COLUMN shelf_rank integer NOT NULL DEFAULT 0;
+4 -3
View File
@@ -253,11 +253,12 @@ SELECT id, user_id, name, description, is_public, kind, system_variant,
-- name: CreateSystemPlaylist :one
-- Inserts a system-generated playlist. Used by BuildSystemPlaylists.
-- For 'for_you' variant, pass seed_artist_id as NULL (zero-value pgtype.UUID
-- with Valid=false).
-- with Valid=false). shelf_rank is the mix's place on its Home shelf, 1
-- first, or 0 for kinds the clients order themselves.
INSERT INTO playlists (
user_id, name, description, is_public,
kind, system_variant, seed_artist_id, cover_path
) VALUES ($1, $2, sqlc.arg(description), false, 'system', $3, $4, $5)
kind, system_variant, seed_artist_id, cover_path, shelf_rank
) VALUES ($1, $2, sqlc.arg(description), false, 'system', $3, $4, $5, sqlc.arg(shelf_rank))
RETURNING *;
-- name: GetSystemPlaylistByVariantForUser :one