diff --git a/lib/music_library_web/controllers/stats_controller.ex b/lib/music_library_web/controllers/stats_controller.ex index 51fe8d25..82cf877a 100644 --- a/lib/music_library_web/controllers/stats_controller.ex +++ b/lib/music_library_web/controllers/stats_controller.ex @@ -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!() diff --git a/lib/music_library_web/controllers/stats_html.ex b/lib/music_library_web/controllers/stats_html.ex index fd2d0f33..726d7d7f 100644 --- a/lib/music_library_web/controllers/stats_html.ex +++ b/lib/music_library_web/controllers/stats_html.ex @@ -6,13 +6,4 @@ defmodule MusicLibraryWeb.StatsHTML do alias MusicLibrary.Records.Record embed_templates "stats_html/*" - - defp format_records_count(records_count_by_format) do - records_count_by_format - |> Enum.sort_by(fn {_format, count} -> count end, :desc) - |> Enum.map(fn {format, count} -> - Integer.to_string(count) <> " " <> Record.format_long_label(format) - end) - |> Enum.join(", ") - end end diff --git a/lib/music_library_web/controllers/stats_html/index.html.heex b/lib/music_library_web/controllers/stats_html/index.html.heex index 383faee2..e3330341 100644 --- a/lib/music_library_web/controllers/stats_html/index.html.heex +++ b/lib/music_library_web/controllers/stats_html/index.html.heex @@ -1,59 +1,24 @@
Total Records
-<%= @records_count %>
-- <%= format_records_count(@records_count_by_format) %> -
-Latest record
++ Latest record +
- + <%= format_artist_names(@latest_record.artists) %> - <%= @latest_record.title %> + + <%= @latest_record.title %> +
Total Records
+<%= @records_count %>
+