From 641ba3e1b7729410146fd3138f67b6f6dbfda948 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 29 Sep 2025 18:40:50 +0300 Subject: [PATCH] Improve heuristics to render artist links for scrobbled tracks --- lib/music_library_web/live/stats_live/index.ex | 4 ++++ .../live/stats_live/index.html.heex | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/music_library_web/live/stats_live/index.ex b/lib/music_library_web/live/stats_live/index.ex index 244c715b..1a9e248f 100644 --- a/lib/music_library_web/live/stats_live/index.ex +++ b/lib/music_library_web/live/stats_live/index.ex @@ -166,4 +166,8 @@ defmodule MusicLibraryWeb.StatsLive.Index do track_or_album.cover_url end end + + defp artist_id(track_or_album, record_artist_id) do + record_artist_id || track_or_album.artist.musicbrainz_id + end end diff --git a/lib/music_library_web/live/stats_live/index.html.heex b/lib/music_library_web/live/stats_live/index.html.heex index 3f6850a3..3e12d43d 100644 --- a/lib/music_library_web/live/stats_live/index.html.heex +++ b/lib/music_library_web/live/stats_live/index.html.heex @@ -114,15 +114,15 @@ />

{album.artist.name}

<.link - :if={artist_id} + :if={artist_id(album, artist_id)} class="font-semibold text-sm block text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300" - navigate={~p"/artists/#{album.artist.musicbrainz_id}"} + navigate={~p"/artists/#{artist_id(album, artist_id)}"} > {album.artist.name} @@ -299,15 +299,15 @@ />

{track.artist.name}

<.link - :if={artist_id} + :if={artist_id(track, artist_id)} class="font-semibold text-sm block text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300" - navigate={~p"/artists/#{artist_id}"} + navigate={~p"/artists/#{artist_id(track, artist_id)}"} > {track.artist.name}