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
+39 -2
View File
@@ -75,6 +75,11 @@ type PlaylistRow struct {
SystemVariant *string // 'for_you' | 'songs_like_artist' | nil
SeedArtistID pgtype.UUID // Valid=true only for 'songs_like_artist'
CoverPath *string
// CoverAlbumIDs are up to six distinct albums with cover art, in the
// order they first appear in the playlist. Filled by List and Get;
// empty for a playlist with no covers, and on the rows Create and
// Update return.
CoverAlbumIDs []pgtype.UUID
TrackCount int32
DurationSec int32
CreatedAt pgtype.Timestamptz
@@ -200,10 +205,16 @@ func (s *Service) Get(ctx context.Context, callerID, playlistID pgtype.UUID) (*P
tracks = append(tracks, pt)
}
return &PlaylistDetail{
detail := &PlaylistDetail{
PlaylistRow: *playlistFromGetRow(row),
Tracks: tracks,
}, nil
}
covers, err := coverAlbums(ctx, q, []pgtype.UUID{playlistID})
if err != nil {
return nil, err
}
detail.CoverAlbumIDs = covers[playlistID]
return detail, nil
}
// List returns all playlists visible to callerID: every playlist owned
@@ -216,8 +227,34 @@ func (s *Service) List(ctx context.Context, callerID pgtype.UUID) ([]PlaylistRow
return nil, fmt.Errorf("list playlists: %w", err)
}
out := make([]PlaylistRow, 0, len(rows))
ids := make([]pgtype.UUID, 0, len(rows))
for _, r := range rows {
out = append(out, *playlistFromListRow(r))
ids = append(ids, r.ID)
}
covers, err := coverAlbums(ctx, q, ids)
if err != nil {
return nil, err
}
for i := range out {
out[i].CoverAlbumIDs = covers[out[i].ID]
}
return out, nil
}
// coverAlbums looks up the cover albums of several playlists in one query,
// keyed by playlist id. A playlist with no covered albums is absent.
func coverAlbums(ctx context.Context, q *dbq.Queries, ids []pgtype.UUID) (map[pgtype.UUID][]pgtype.UUID, error) {
out := make(map[pgtype.UUID][]pgtype.UUID, len(ids))
if len(ids) == 0 {
return out, nil
}
rows, err := q.ListPlaylistCoverAlbums(ctx, ids)
if err != nil {
return nil, fmt.Errorf("list cover albums: %w", err)
}
for _, r := range rows {
out[r.PlaylistID] = r.AlbumIds
}
return out, nil
}