diff --git a/lib/music_library_web/controllers/stats_controller.ex b/lib/music_library_web/controllers/stats_controller.ex new file mode 100644 index 00000000..4e766cef --- /dev/null +++ b/lib/music_library_web/controllers/stats_controller.ex @@ -0,0 +1,10 @@ +defmodule MusicLibraryWeb.StatsController do + use MusicLibraryWeb, :controller + + alias MusicLibrary.Records + + def index(conn, _params) do + records_count = Records.count_records() + render(conn, :index, records_count: records_count) + end +end diff --git a/lib/music_library_web/controllers/stats_html.ex b/lib/music_library_web/controllers/stats_html.ex new file mode 100644 index 00000000..e7e4fe94 --- /dev/null +++ b/lib/music_library_web/controllers/stats_html.ex @@ -0,0 +1,5 @@ +defmodule MusicLibraryWeb.StatsHTML do + use MusicLibraryWeb, :html + + embed_templates "stats_html/*" +end diff --git a/lib/music_library_web/controllers/stats_html/index.html.heex b/lib/music_library_web/controllers/stats_html/index.html.heex new file mode 100644 index 00000000..f8373a65 --- /dev/null +++ b/lib/music_library_web/controllers/stats_html/index.html.heex @@ -0,0 +1,13 @@ +
+

Music Library

+
+
+
Total Records
+
+
+ <%= @records_count %> +
+
+
+
+
diff --git a/lib/music_library_web/router.ex b/lib/music_library_web/router.ex index df87a45e..f78e41dc 100644 --- a/lib/music_library_web/router.ex +++ b/lib/music_library_web/router.ex @@ -19,8 +19,8 @@ defmodule MusicLibraryWeb.Router do get "/health", HealthController, :index get "/images/:record_id", ImageController, :show + get "/", StatsController, :index - live "/", RecordLive.Index, :index live "/records", RecordLive.Index, :index live "/records/import", RecordLive.Index, :import live "/records/:id/edit", RecordLive.Index, :edit