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
)
@@ -11,7 +11,7 @@
alt={@latest_record.title}
/>
<p class="ml-24 truncate text-xs sm:text-sm font-medium text-gray-500">
<%= gettext("Latest record") %>
<%= gettext("Latest purchase") %>
</p>
</dt>
<dd class="ml-24 flex items-baseline pb-6 sm:pb-7">
@@ -31,11 +31,13 @@
</div>
<div class="overflow-hidden rounded-lg bg-white px-4 pb-3 pt-5 shadow sm:px-6 sm:pt-6">
<dt>
<p class="truncate text-sm font-medium text-gray-500"><%= gettext("Total Records") %></p>
<p class="truncate text-sm font-medium text-gray-500">
<%= gettext("Total collection") %>
</p>
</dt>
<dd class="flex items-baseline pb-6 sm:pb-7">
<a href={~p"/records"} class="text-2xl font-semibold text-gray-900 hover:text-gray-500">
<%= @records_count %>
<%= @collection_count %>
</a>
</dd>
</div>
@@ -44,7 +46,7 @@
<div>
<dl class="mt-5 grid divide-y divide-gray-200 overflow-hidden rounded-lg bg-white shadow grid-cols-5 md:divide-x md:divide-y-0">
<div :for={{format, count} <- @records_count_by_format} class="px-4 py-5 sm:p-6">
<div :for={{format, count} <- @collection_count_by_format} class="px-4 py-5 sm:p-6">
<dt class="text-base max-sm:text-xs font-normal text-gray-900 break-keep">
<%= Record.format_long_label(format) %>
</dt>
@@ -61,7 +63,7 @@
<div>
<dl class="mt-5 grid divide-y divide-gray-200 overflow-hidden rounded-lg bg-white shadow grid-cols-6 md:divide-x md:divide-y-0">
<div :for={{type, count} <- @records_count_by_type} class="px-4 py-5 sm:p-6">
<div :for={{type, count} <- @collection_count_by_type} class="px-4 py-5 sm:p-6">
<dt class="text-base max-sm:text-xs font-normal text-gray-900 break-keep">
<%= Record.type_long_label(type) %>
</dt>
+11 -11
View File
@@ -84,7 +84,7 @@ msgid "Logout"
msgstr ""
#: lib/music_library_web/components/layouts/app.html.heex:7
#: lib/music_library_web/controllers/stats_controller.ex:19
#: lib/music_library_web/controllers/stats_controller.ex:21
#, elixir-autogen, elixir-format
msgid "Stats"
msgstr ""
@@ -101,16 +101,6 @@ msgstr ""
msgid "Previous"
msgstr ""
#: lib/music_library_web/controllers/stats_html/index.html.heex:14
#, elixir-autogen, elixir-format
msgid "Latest record"
msgstr ""
#: lib/music_library_web/controllers/stats_html/index.html.heex:34
#, elixir-autogen, elixir-format
msgid "Total Records"
msgstr ""
#: lib/music_library_web/live/record_live/form_component.ex:34
#: lib/music_library_web/live/record_live/form_component.ex:41
#, elixir-autogen, elixir-format
@@ -324,3 +314,13 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Login"
msgstr ""
#: lib/music_library_web/controllers/stats_html/index.html.heex:14
#, elixir-autogen, elixir-format
msgid "Latest purchase"
msgstr ""
#: lib/music_library_web/controllers/stats_html/index.html.heex:35
#, elixir-autogen, elixir-format
msgid "Total collection"
msgstr ""