Extract stats data grid component

This commit is contained in:
Claudio Ortolina
2024-10-30 08:37:49 +00:00
parent f23031821c
commit 432f09cf6f
5 changed files with 259 additions and 247 deletions
@@ -1,16 +1,20 @@
defmodule MusicLibraryWeb.StatsLive.Index do
use MusicLibraryWeb, :live_view
import MusicLibraryWeb.StatsLive.DataComponents
alias MusicLibrary.{Records, Wishlist}
alias Records.Record
def mount(_params, _session, socket) do
collection_count_by_format =
Records.count_records_by_format()
|> Enum.map(fn {format, count} -> {Record.format_long_label(format), count} end)
|> Enum.sort_by(fn {_format, count} -> count end, :desc)
collection_count_by_type =
Records.count_records_by_type()
|> Enum.map(fn {type, count} -> {Record.type_long_label(type), count} end)
|> Enum.sort_by(fn {_type, count} -> count end, :desc)
collection_count =