Make stats formats and types counters sync
This commit is contained in:
@@ -45,29 +45,10 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
</div>
|
</div>
|
||||||
</.section>
|
</.section>
|
||||||
|
|
||||||
<.async_result :let={summary} assign={@collection_summary}>
|
<div :if={@collection_count > 0} class="grid gap-x-5 md:grid-cols-2">
|
||||||
<:loading>
|
<.formats_stats collection_count_by_format={@collection_count_by_format} />
|
||||||
<div class="grid gap-x-5 md:grid-cols-2">
|
<.types_stats collection_count_by_type={@collection_count_by_type} />
|
||||||
<.section>
|
</div>
|
||||||
<:title>{gettext("Formats")}</:title>
|
|
||||||
<div class="mt-5 rounded-md bg-white p-6 shadow-sm dark:bg-zinc-800 animate-pulse">
|
|
||||||
<div class="h-4 w-1/3 rounded bg-zinc-200 dark:bg-zinc-700"></div>
|
|
||||||
</div>
|
|
||||||
</.section>
|
|
||||||
<.section>
|
|
||||||
<:title>{gettext("Types")}</:title>
|
|
||||||
<div class="mt-5 rounded-md bg-white p-6 shadow-sm dark:bg-zinc-800 animate-pulse">
|
|
||||||
<div class="h-4 w-1/3 rounded bg-zinc-200 dark:bg-zinc-700"></div>
|
|
||||||
</div>
|
|
||||||
</.section>
|
|
||||||
</div>
|
|
||||||
</:loading>
|
|
||||||
<:failed :let={_reason}></:failed>
|
|
||||||
<div :if={@collection_count > 0} class="grid gap-x-5 md:grid-cols-2">
|
|
||||||
<.formats_stats collection_count_by_format={summary.collection_count_by_format} />
|
|
||||||
<.types_stats collection_count_by_type={summary.collection_count_by_type} />
|
|
||||||
</div>
|
|
||||||
</.async_result>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-x-5 md:grid-cols-2 lg:grid-cols-3">
|
<div class="grid grid-cols-1 gap-x-5 md:grid-cols-2 lg:grid-cols-3">
|
||||||
<TopArtists.live id="top-artists" timezone={@timezone} last_updated_uts={@last_updated_uts} />
|
<TopArtists.live id="top-artists" timezone={@timezone} last_updated_uts={@last_updated_uts} />
|
||||||
@@ -165,6 +146,8 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
collection_count: Collection.count(),
|
collection_count: Collection.count(),
|
||||||
wishlist_count: Wishlist.count(),
|
wishlist_count: Wishlist.count(),
|
||||||
scrobble_count: ListeningStats.scrobble_count(),
|
scrobble_count: ListeningStats.scrobble_count(),
|
||||||
|
collection_count_by_format: Collection.count_records_by_format(),
|
||||||
|
collection_count_by_type: Collection.count_records_by_type(),
|
||||||
last_updated_uts: nil,
|
last_updated_uts: nil,
|
||||||
scrobble_activity_mode: "albums",
|
scrobble_activity_mode: "albums",
|
||||||
page_title: gettext("Stats"),
|
page_title: gettext("Stats"),
|
||||||
@@ -175,8 +158,6 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
{:ok,
|
{:ok,
|
||||||
%{
|
%{
|
||||||
collection_summary: %{
|
collection_summary: %{
|
||||||
collection_count_by_format: Collection.count_records_by_format(),
|
|
||||||
collection_count_by_type: Collection.count_records_by_type(),
|
|
||||||
records_by_artist: Collection.count_records_by_artist(limit: 20),
|
records_by_artist: Collection.count_records_by_artist(limit: 20),
|
||||||
records_by_genre: Collection.count_records_by_genre(limit: 20),
|
records_by_genre: Collection.count_records_by_genre(limit: 20),
|
||||||
records_by_release_year: Collection.count_records_by_release_year(limit: 20)
|
records_by_release_year: Collection.count_records_by_release_year(limit: 20)
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ defmodule MusicLibraryWeb.StatsLive.IndexTest do
|
|||||||
conn
|
conn
|
||||||
|> visit("/")
|
|> visit("/")
|
||||||
|> assert_has("dd", collection |> length() |> Integer.to_string())
|
|> assert_has("dd", collection |> length() |> Integer.to_string())
|
||||||
|> render_async()
|
|
||||||
|
|
||||||
collection
|
collection
|
||||||
|> Enum.frequencies_by(& &1.format)
|
|> Enum.frequencies_by(& &1.format)
|
||||||
|
|||||||
Reference in New Issue
Block a user