Rename counts in stats

This commit is contained in:
Claudio Ortolina
2024-10-22 18:14:15 +01:00
parent e8d5ee06cf
commit 8e654fb782
3 changed files with 26 additions and 22 deletions
@@ -4,23 +4,25 @@ defmodule MusicLibraryWeb.StatsController do
alias MusicLibrary.Records
def index(conn, _params) do
records_count_by_format =
collection_count_by_format =
Records.count_records_by_format()
|> Enum.sort_by(fn {_format, count} -> count end, :desc)
records_count_by_type =
collection_count_by_type =
Records.count_records_by_type()
|> Enum.sort_by(fn {_type, count} -> count end, :desc)
records_count = Enum.reduce(records_count_by_format, 0, fn {_, count}, acc -> acc + count end)
collection_count =
Enum.reduce(collection_count_by_format, 0, fn {_, count}, acc -> acc + count end)
latest_record = Records.get_latest_record!()
conn
|> assign(:page_title, gettext("Stats"))
|> render(:index,
records_count_by_format: records_count_by_format,
records_count_by_type: records_count_by_type,
records_count: records_count,
collection_count_by_format: collection_count_by_format,
collection_count_by_type: collection_count_by_type,
collection_count: collection_count,
latest_record: latest_record,
nav_section: :stats
)