Include artists and cover in latest record JSON

This commit is contained in:
Claudio Ortolina
2024-12-22 15:55:41 +00:00
parent 75506b6e1c
commit 341d276db5
3 changed files with 20 additions and 3 deletions
@@ -1,5 +1,11 @@
defmodule MusicLibraryWeb.CollectionJSON do
use MusicLibraryWeb, :json
def show(%{record: record}) do
Map.take(record, [:title])
%{
artists: Enum.map(record.artists, & &1.name),
title: record.title,
cover_url: url(~p"/covers/#{record.id}?#{[vsn: record.cover_hash]}")
}
end
end