Display 50 rows of charts

This commit is contained in:
Claudio Ortolina
2025-04-06 19:31:12 +01:00
parent 582eb8d031
commit ddd81ff7dd
2 changed files with 10 additions and 4 deletions
+6 -2
View File
@@ -71,7 +71,9 @@ defmodule MusicLibrary.Collection do
Repo.all(q)
end
def count_records_by_artist(limit \\ 30) do
def count_records_by_artist(opts \\ []) do
limit = Keyword.get(opts, :limit, 30)
q =
from r in fragment("records, json_each(records.artists)"),
where: fragment("records.purchased_at IS NOT NULL"),
@@ -87,7 +89,9 @@ defmodule MusicLibrary.Collection do
Repo.all(q)
end
def count_records_by_genre(limit \\ 30) do
def count_records_by_genre(opts \\ []) do
limit = Keyword.get(opts, :limit, 30)
q =
from r in fragment("records, json_each(records.genres)"),
where: fragment("records.purchased_at IS NOT NULL"),
@@ -10,6 +10,8 @@ defmodule MusicLibraryWeb.StatsLive.Index do
def mount(_params, _session, socket) do
latest_record = Collection.get_latest_record!()
recent_tracks = LastFm.get_scrobbled_tracks()
records_by_artists = Collection.count_records_by_artist(limit: 50)
records_by_genre = Collection.count_records_by_genre(limit: 50)
if connected?(socket) do
LastFm.subscribe_to_feed()
@@ -30,8 +32,8 @@ defmodule MusicLibraryWeb.StatsLive.Index do
latest_record: latest_record,
page_title: gettext("Stats"),
nav_section: :stats,
records_by_artist: Collection.count_records_by_artist(),
records_by_genre: Collection.count_records_by_genre()
records_by_artist: records_by_artists,
records_by_genre: records_by_genre
)}
end