Restructure stats

Split out count by format
This commit is contained in:
Claudio Ortolina
2024-10-08 20:36:39 +01:00
parent 36f1d44468
commit 52c1be1e32
4 changed files with 32 additions and 56 deletions
@@ -4,7 +4,10 @@ defmodule MusicLibraryWeb.StatsController do
alias MusicLibrary.Records
def index(conn, _params) do
records_count_by_format = Records.count_records_by_format()
records_count_by_format =
Records.count_records_by_format()
|> Enum.sort_by(fn {_format, count} -> count end, :desc)
records_count = Enum.reduce(records_count_by_format, 0, fn {_, count}, acc -> acc + count end)
latest_record = Records.get_latest_record!()