From 36f27c76e89b97f7940fe028d0a0e20d5954f824 Mon Sep 17 00:00:00 2001 From: Kieran Date: Fri, 1 Mar 2024 18:25:55 -0800 Subject: [PATCH] Useful data on homepage v1 (#43) * Made the homepage _slightly_ more useful * Very minor refactor in alpine body-level object --- .../components/layouts/root.html.heex | 2 +- .../controllers/pages/page_controller.ex | 12 +++++++- .../pages/page_html/home.html.heex | 29 +++++++++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/lib/pinchflat_web/components/layouts/root.html.heex b/lib/pinchflat_web/components/layouts/root.html.heex index 8dbdc8d..c562aa7 100644 --- a/lib/pinchflat_web/components/layouts/root.html.heex +++ b/lib/pinchflat_web/components/layouts/root.html.heex @@ -12,7 +12,7 @@ - + <%= @inner_content %> diff --git a/lib/pinchflat_web/controllers/pages/page_controller.ex b/lib/pinchflat_web/controllers/pages/page_controller.ex index 8f5a0bc..5265796 100644 --- a/lib/pinchflat_web/controllers/pages/page_controller.ex +++ b/lib/pinchflat_web/controllers/pages/page_controller.ex @@ -1,8 +1,10 @@ defmodule PinchflatWeb.Pages.PageController do + alias Pinchflat.Media.MediaItem use PinchflatWeb, :controller alias Pinchflat.Repo alias Pinchflat.Sources.Source + alias Pinchflat.Media.MediaItem alias Pinchflat.Profiles.MediaProfile def home(conn, params) do @@ -18,9 +20,17 @@ defmodule PinchflatWeb.Pages.PageController do end defp render_home_page(conn) do + media_profile_count = Repo.aggregate(MediaProfile, :count, :id) + source_count = Repo.aggregate(Source, :count, :id) + media_item_count = Repo.aggregate(MediaItem, :count, :id) + conn |> put_session(:onboarding, false) - |> render(:home) + |> render(:home, + media_profile_count: media_profile_count, + source_count: source_count, + media_item_count: media_item_count + ) end defp render_onboarding_page(conn, media_profiles_exist, sources_exist) do diff --git a/lib/pinchflat_web/controllers/pages/page_html/home.html.heex b/lib/pinchflat_web/controllers/pages/page_html/home.html.heex index cecaf9e..a21d152 100644 --- a/lib/pinchflat_web/controllers/pages/page_html/home.html.heex +++ b/lib/pinchflat_web/controllers/pages/page_html/home.html.heex @@ -1,8 +1,27 @@ -
-
-
-

TODO: Put some useful info or analytics here

-

For now, the options in the sidebar have what you need

+
+
+
+ Media Profile(s) +

+ <%= @media_profile_count %> +

+
+
+ Source(s) +

+ <%= @source_count %> +

+
+
+
+
+ Media Item(s) +

+ <%= @media_item_count %> +

+
+
+ I know this page isn't super useful yet, but give it time :)