Link to artist page in count by artist chart

This commit is contained in:
Claudio Ortolina
2025-04-06 17:49:22 +01:00
parent 4fdd2e7ea6
commit 6777d716fa
2 changed files with 9 additions and 5 deletions
+5 -1
View File
@@ -77,7 +77,11 @@ defmodule MusicLibrary.Collection do
where: fragment("records.purchased_at IS NOT NULL"),
group_by: fragment("json_extract(?, '$.name')", r.value),
order_by: [desc: fragment("count(1)")],
select: {fragment("json_extract(?, '$.name')", r.value), fragment("count(1)")},
select: %{
id: fragment("json_extract(?, '$.musicbrainz_id')", r.value),
name: fragment("json_extract(?, '$.name')", r.value),
count: fragment("count(1)")
},
limit: ^limit
Repo.all(q)
@@ -79,11 +79,11 @@
width={600}
height={35 * length(@records_by_artist)}
bar_color="rgb(79, 70, 229)"
label_fn={fn {artist, _count} -> artist end}
value_fn={fn {_artist, count} -> count end}
label_fn={fn datum -> datum.name end}
value_fn={fn datum -> datum.count end}
label_click={
fn {artist, _count} ->
JS.navigate(~p"/collection?#{%{query: ~s(artist:"#{artist}")}}")
fn datum ->
JS.navigate(~p"/artists/#{datum.id}")
end
}
class="w-full"