Add stats for last 7 days

This commit is contained in:
Claudio Ortolina
2025-09-23 16:01:35 +03:00
parent 5d507a357b
commit 03a57823dc
5 changed files with 76 additions and 46 deletions
@@ -20,13 +20,21 @@ defmodule MusicLibraryWeb.StatsLive.TopAlbums do
</h1>
<.tabs class="mt-4">
<.tabs_list active_tab={name_from_period(@period)} variant="segmented" size="xs">
<:tab
class="flex-1"
name="top_albums_last_7_days"
phx-click={JS.push("set_period", value: %{period: "last_7_days"})}
phx-target={@myself}
>
{gettext("7d")}
</:tab>
<:tab
class="flex-1"
name="top_albums_last_30_days"
phx-click={JS.push("set_period", value: %{period: "last_30_days"})}
phx-target={@myself}
>
{gettext("30 days")}
{gettext("30d")}
</:tab>
<:tab
class="flex-1"
@@ -34,7 +42,7 @@ defmodule MusicLibraryWeb.StatsLive.TopAlbums do
phx-click={JS.push("set_period", value: %{period: "last_90_days"})}
phx-target={@myself}
>
{gettext("90 days")}
{gettext("90d")}
</:tab>
<:tab
class="flex-1"
@@ -42,7 +50,7 @@ defmodule MusicLibraryWeb.StatsLive.TopAlbums do
phx-click={JS.push("set_period", value: %{period: "last_365_days"})}
phx-target={@myself}
>
{gettext("Last year")}
{gettext("1y")}
</:tab>
<:tab
class="flex-1"
@@ -76,7 +84,7 @@ defmodule MusicLibraryWeb.StatsLive.TopAlbums do
def mount(socket) do
{:ok,
socket
|> assign(:period, :last_30_days)}
|> assign(:period, :last_7_days)}
end
@impl true
@@ -20,13 +20,21 @@ defmodule MusicLibraryWeb.StatsLive.TopArtists do
</h1>
<.tabs class="mt-4">
<.tabs_list active_tab={name_from_period(@period)} variant="segmented" size="xs">
<:tab
class="flex-1"
name="top_artists_last_7_days"
phx-click={JS.push("set_period", value: %{period: "last_7_days"})}
phx-target={@myself}
>
{gettext("7d")}
</:tab>
<:tab
class="flex-1"
name="top_artists_last_30_days"
phx-click={JS.push("set_period", value: %{period: "last_30_days"})}
phx-target={@myself}
>
{gettext("30 days")}
{gettext("30d")}
</:tab>
<:tab
class="flex-1"
@@ -34,7 +42,7 @@ defmodule MusicLibraryWeb.StatsLive.TopArtists do
phx-click={JS.push("set_period", value: %{period: "last_90_days"})}
phx-target={@myself}
>
{gettext("90 days")}
{gettext("90d")}
</:tab>
<:tab
class="flex-1"
@@ -42,7 +50,7 @@ defmodule MusicLibraryWeb.StatsLive.TopArtists do
phx-click={JS.push("set_period", value: %{period: "last_365_days"})}
phx-target={@myself}
>
{gettext("Last year")}
{gettext("1y")}
</:tab>
<:tab
class="flex-1"
@@ -72,7 +80,7 @@ defmodule MusicLibraryWeb.StatsLive.TopArtists do
def mount(socket) do
{:ok,
socket
|> assign(:period, :last_30_days)}
|> assign(:period, :last_7_days)}
end
@impl true