Consolidate handling of artist joinphrases
This commit is contained in:
@@ -20,7 +20,10 @@ defmodule MusicBrainz.ReleaseGroupSearchResult do
|
||||
id: rg["id"],
|
||||
type: ReleaseGroup.parse_type(rg["primary-type"]),
|
||||
title: rg["title"],
|
||||
artists: Enum.map_join(rg["artist-credit"], ", ", fn ac -> ac["artist"]["name"] end),
|
||||
artists:
|
||||
Enum.map_join(rg["artist-credit"], fn ac ->
|
||||
ac["artist"]["name"] <> (ac["joinphrase"] || "")
|
||||
end),
|
||||
release_date: rg["first-release-date"]
|
||||
}
|
||||
end
|
||||
|
||||
@@ -37,7 +37,9 @@ defmodule MusicLibrary.Records.Record do
|
||||
|
||||
@spec artist_names(t()) :: String.t()
|
||||
def artist_names(record) do
|
||||
Enum.map_join(record.artists, ", ", fn artist -> artist.name end)
|
||||
record.artists
|
||||
|> Enum.map_join(fn artist -> artist.name <> artist.joinphrase end)
|
||||
|> String.trim()
|
||||
end
|
||||
|
||||
@spec main_artist(t()) :: Artist.t() | nil
|
||||
|
||||
@@ -41,13 +41,7 @@ defmodule MusicLibraryWeb.StatsComponents do
|
||||
<span class="text-sm md:text-base lg:text-2xl block text-zinc-900 dark:text-zinc-300">
|
||||
{@record.title}
|
||||
</span>
|
||||
<.link
|
||||
:for={artist <- @record.artists}
|
||||
class="text-sm md:text-base text-zinc-600 dark:text-zinc-300 hover:text-zinc-500 dark:hover:text-zinc-200"
|
||||
navigate={~p"/artists/#{artist.musicbrainz_id}"}
|
||||
>
|
||||
{artist.name}
|
||||
</.link>
|
||||
<.artist_links artists={@record.artists} joinphrase_class="text-sm md:text-base" />
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -171,8 +171,7 @@ defmodule MusicLibrary.Records.SimilarityTest do
|
||||
|
||||
text = Similarity.text_representation(record)
|
||||
|
||||
# Record.artist_names joins with ", " not with joinphrase
|
||||
assert text =~ "Artists: Artist One, Artist Two"
|
||||
assert text =~ "Artists: Artist One & Artist Two"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user