Rename counts in stats
This commit is contained in:
@@ -4,23 +4,25 @@ defmodule MusicLibraryWeb.StatsController do
|
|||||||
alias MusicLibrary.Records
|
alias MusicLibrary.Records
|
||||||
|
|
||||||
def index(conn, _params) do
|
def index(conn, _params) do
|
||||||
records_count_by_format =
|
collection_count_by_format =
|
||||||
Records.count_records_by_format()
|
Records.count_records_by_format()
|
||||||
|> Enum.sort_by(fn {_format, count} -> count end, :desc)
|
|> Enum.sort_by(fn {_format, count} -> count end, :desc)
|
||||||
|
|
||||||
records_count_by_type =
|
collection_count_by_type =
|
||||||
Records.count_records_by_type()
|
Records.count_records_by_type()
|
||||||
|> Enum.sort_by(fn {_type, count} -> count end, :desc)
|
|> 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!()
|
latest_record = Records.get_latest_record!()
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> assign(:page_title, gettext("Stats"))
|
|> assign(:page_title, gettext("Stats"))
|
||||||
|> render(:index,
|
|> render(:index,
|
||||||
records_count_by_format: records_count_by_format,
|
collection_count_by_format: collection_count_by_format,
|
||||||
records_count_by_type: records_count_by_type,
|
collection_count_by_type: collection_count_by_type,
|
||||||
records_count: records_count,
|
collection_count: collection_count,
|
||||||
latest_record: latest_record,
|
latest_record: latest_record,
|
||||||
nav_section: :stats
|
nav_section: :stats
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
alt={@latest_record.title}
|
alt={@latest_record.title}
|
||||||
/>
|
/>
|
||||||
<p class="ml-24 truncate text-xs sm:text-sm font-medium text-gray-500">
|
<p class="ml-24 truncate text-xs sm:text-sm font-medium text-gray-500">
|
||||||
<%= gettext("Latest record") %>
|
<%= gettext("Latest purchase") %>
|
||||||
</p>
|
</p>
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="ml-24 flex items-baseline pb-6 sm:pb-7">
|
<dd class="ml-24 flex items-baseline pb-6 sm:pb-7">
|
||||||
@@ -31,11 +31,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="overflow-hidden rounded-lg bg-white px-4 pb-3 pt-5 shadow sm:px-6 sm:pt-6">
|
<div class="overflow-hidden rounded-lg bg-white px-4 pb-3 pt-5 shadow sm:px-6 sm:pt-6">
|
||||||
<dt>
|
<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>
|
</dt>
|
||||||
<dd class="flex items-baseline pb-6 sm:pb-7">
|
<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">
|
<a href={~p"/records"} class="text-2xl font-semibold text-gray-900 hover:text-gray-500">
|
||||||
<%= @records_count %>
|
<%= @collection_count %>
|
||||||
</a>
|
</a>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
@@ -44,7 +46,7 @@
|
|||||||
|
|
||||||
<div>
|
<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">
|
<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">
|
<dt class="text-base max-sm:text-xs font-normal text-gray-900 break-keep">
|
||||||
<%= Record.format_long_label(format) %>
|
<%= Record.format_long_label(format) %>
|
||||||
</dt>
|
</dt>
|
||||||
@@ -61,7 +63,7 @@
|
|||||||
|
|
||||||
<div>
|
<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">
|
<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">
|
<dt class="text-base max-sm:text-xs font-normal text-gray-900 break-keep">
|
||||||
<%= Record.type_long_label(type) %>
|
<%= Record.type_long_label(type) %>
|
||||||
</dt>
|
</dt>
|
||||||
|
|||||||
+11
-11
@@ -84,7 +84,7 @@ msgid "Logout"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/components/layouts/app.html.heex:7
|
#: 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
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Stats"
|
msgid "Stats"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -101,16 +101,6 @@ msgstr ""
|
|||||||
msgid "Previous"
|
msgid "Previous"
|
||||||
msgstr ""
|
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:34
|
||||||
#: lib/music_library_web/live/record_live/form_component.ex:41
|
#: lib/music_library_web/live/record_live/form_component.ex:41
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
@@ -324,3 +314,13 @@ msgstr ""
|
|||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Login"
|
msgid "Login"
|
||||||
msgstr ""
|
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 ""
|
||||||
|
|||||||
Reference in New Issue
Block a user