feat(playlists): playlists list their cover albums, and system mixes say what they hold
release / go (push) Successful in 2m2s
release / web (push) Successful in 1m26s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 4m11s
release / android (push) Successful in 4m10s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 2m48s

Each playlist on the wire (list and get) carries cover_album_ids: up to
six distinct albums with art, in the order they first appear. A shelf of
playlist tiles takes each tile's first album that no tile before it
shows, so no cover repeats along the shelf.

System mixes are stored with a one-line description of what they are
built from, written in one place so the web and Android apps show the
same words. Songs like and genre mixes have none; their names say it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 15:59:44 -05:00
co-authored by Claude Opus 5.5
parent 0e2538e888
commit ec017838a2
8 changed files with 256 additions and 8 deletions
+45
View File
@@ -260,6 +260,51 @@ func (q *Queries) ListAllPlaylistTracksForCollage(ctx context.Context, arg ListA
return items, nil
}
const listPlaylistCoverAlbums = `-- name: ListPlaylistCoverAlbums :many
SELECT s.playlist_id,
(array_agg(s.album_id ORDER BY s.first_position))[1:6]::uuid[] AS album_ids
FROM (
SELECT pt.playlist_id, t.album_id, MIN(pt.position) AS first_position
FROM playlist_tracks pt
JOIN tracks t ON t.id = pt.track_id
JOIN albums a ON a.id = t.album_id
WHERE pt.playlist_id = ANY($1::uuid[])
AND a.cover_art_path IS NOT NULL
AND a.cover_art_path <> ''
GROUP BY pt.playlist_id, t.album_id
) s
GROUP BY s.playlist_id
`
type ListPlaylistCoverAlbumsRow struct {
PlaylistID pgtype.UUID
AlbumIds []pgtype.UUID
}
// The albums a playlist's tiles can show: up to six distinct albums with
// cover art per playlist, in the order they first appear in its tracks.
// More than one per playlist, so a shelf of tiles can give each one a
// cover no other tile on the shelf is already showing.
func (q *Queries) ListPlaylistCoverAlbums(ctx context.Context, playlistIds []pgtype.UUID) ([]ListPlaylistCoverAlbumsRow, error) {
rows, err := q.db.Query(ctx, listPlaylistCoverAlbums, playlistIds)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListPlaylistCoverAlbumsRow
for rows.Next() {
var i ListPlaylistCoverAlbumsRow
if err := rows.Scan(&i.PlaylistID, &i.AlbumIds); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listPlaylistTracks = `-- name: ListPlaylistTracks :many
SELECT pt.playlist_id, pt.position, pt.track_id, pt.title, pt.artist_name, pt.album_title, pt.duration_sec, pt.added_at, pt.pick_kind,
t.id AS live_track_id,
+3 -1
View File
@@ -27,7 +27,7 @@ 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, '', false, 'system', $3, $4, $5)
) 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
`
@@ -37,6 +37,7 @@ type CreateSystemPlaylistParams struct {
SystemVariant *string
SeedArtistID pgtype.UUID
CoverPath *string
Description string
}
// Inserts a system-generated playlist. Used by BuildSystemPlaylists.
@@ -49,6 +50,7 @@ func (q *Queries) CreateSystemPlaylist(ctx context.Context, arg CreateSystemPlay
arg.SystemVariant,
arg.SeedArtistID,
arg.CoverPath,
arg.Description,
)
var i Playlist
err := row.Scan(