feat(api): GET /api/home/index for per-item rendering (Slice B)
Sibling to /api/home that returns the same five sections (recently added, rediscover albums, rediscover artists, most played, last played) but as flat slices of entity ID strings instead of denormalized objects. The Flutter client uses this to drive its per-item rendering pass — small discovery response then per-tile hydration via the existing /api/albums/:id, /api/artists/:id, /api/tracks/:id endpoints. Reuses recommendation.HomeData so the DB cost is identical to /api/home. JSON payload shrinks roughly an order of magnitude on populated libraries (no embedded title / artist / cover URL fields). Old /api/home stays untouched so the web client and older Flutter builds keep working — no min-client-version bump needed until both clients have migrated.
This commit is contained in:
@@ -118,6 +118,24 @@ type HomePayload struct {
|
||||
LastPlayedArtists []ArtistRef `json:"last_played_artists"`
|
||||
}
|
||||
|
||||
// HomeIndexPayload is the response body of GET /api/home/index — the
|
||||
// per-item rendering variant of /api/home. Same sections, same caps,
|
||||
// but each section is a flat slice of entity IDs (UUID strings)
|
||||
// instead of denormalized objects. Slices are non-nil at JSON encode
|
||||
// time so empty sections render as `[]`.
|
||||
//
|
||||
// Client fetches this, then hydrates each tile against the per-entity
|
||||
// endpoints (/api/albums/{id}, /api/artists/{id}, /api/tracks/{id})
|
||||
// for genuine progressive rendering. The section name implies the
|
||||
// entity type so no per-entry type tag is needed.
|
||||
type HomeIndexPayload struct {
|
||||
RecentlyAddedAlbums []string `json:"recently_added_albums"`
|
||||
RediscoverAlbums []string `json:"rediscover_albums"`
|
||||
RediscoverArtists []string `json:"rediscover_artists"`
|
||||
MostPlayedTracks []string `json:"most_played_tracks"`
|
||||
LastPlayedArtists []string `json:"last_played_artists"`
|
||||
}
|
||||
|
||||
// HistoryEvent is one play in a user's listening history. Used by
|
||||
// /api/me/history; one event per row from play_events.
|
||||
type HistoryEvent struct {
|
||||
|
||||
Reference in New Issue
Block a user