Show similar artists in artist page

Styling to be defined - only links for now.
This commit is contained in:
Claudio Ortolina
2025-02-23 16:56:52 +00:00
parent 1193fa5914
commit c67d11da0c
6 changed files with 116 additions and 32 deletions
+15
View File
@@ -14,6 +14,21 @@ defmodule MusicLibrary.Artists do
Repo.one!(q)
end
def get_similar_artists(artist) do
case LastFm.get_similar_artists(artist.musicbrainz_id, artist.name) do
{:ok, artists} ->
all_artist_ids = get_all_artist_ids()
{:ok,
Enum.filter(artists, fn a ->
MapSet.member?(all_artist_ids, a.musicbrainz_id)
end)}
error ->
error
end
end
def get_all_artist_ids do
q = from ar in ArtistRecord, distinct: true, select: ar.musicbrainz_id