diff --git a/lib/pinchflat/media/media_query.ex b/lib/pinchflat/media/media_query.ex index 53e2c35..349e875 100644 --- a/lib/pinchflat/media/media_query.ex +++ b/lib/pinchflat/media/media_query.ex @@ -172,6 +172,12 @@ defmodule Pinchflat.Media.MediaQuery do |> matching_source_title_regex() end + def where_pending_or_downloaded(query) do + query + |> where_pending_download() + |> or_where([mi], not is_nil(mi.media_downloaded_at)) + end + defp require_assoc(query, identifier) do if has_named_binding?(query, identifier) do query diff --git a/lib/pinchflat_web/controllers/pages/page_controller.ex b/lib/pinchflat_web/controllers/pages/page_controller.ex index ef1b154..b66a96b 100644 --- a/lib/pinchflat_web/controllers/pages/page_controller.ex +++ b/lib/pinchflat_web/controllers/pages/page_controller.ex @@ -1,10 +1,9 @@ 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.Media.MediaQuery alias Pinchflat.Profiles.MediaProfile def home(conn, params) do @@ -25,7 +24,10 @@ defmodule PinchflatWeb.Pages.PageController do |> render(:home, media_profile_count: Repo.aggregate(MediaProfile, :count, :id), source_count: Repo.aggregate(Source, :count, :id), - media_item_count: Repo.aggregate(MediaItem, :count, :id) + media_item_count: + MediaQuery.new() + |> MediaQuery.with_media_downloaded_at() + |> Repo.aggregate(:count, :id) ) end diff --git a/lib/pinchflat_web/controllers/pages/page_html/history_table_live.ex b/lib/pinchflat_web/controllers/pages/page_html/history_table_live.ex index bd5c2a7..4d221a2 100644 --- a/lib/pinchflat_web/controllers/pages/page_html/history_table_live.ex +++ b/lib/pinchflat_web/controllers/pages/page_html/history_table_live.ex @@ -24,27 +24,29 @@ defmodule Pinchflat.Pages.HistoryTableLive do <.icon_button icon_name="hero-arrow-path" class="h-10 w-10" phx-click="reload_page" tooltip="Refresh" /> Showing <%= length(@records) %> of <%= @total_record_count %> - <.table rows={@records} table_class="text-white"> - <:col :let={media_item} label="Title"> - <.subtle_link href={~p"/sources/#{media_item.source_id}/media/#{media_item}"}> - <%= StringUtils.truncate(media_item.title, 35) %> - - - <:col :let={media_item} label="Upload Date"> - <%= media_item.upload_date %> - - <:col :let={media_item} label="Indexed At (UTC)"> - <%= format_datetime(media_item.inserted_at) %> - - <:col :let={media_item} label="Downloaded At (UTC)"> - <%= format_datetime(media_item.media_downloaded_at) %> - - <:col :let={media_item} label="Source"> - <.subtle_link href={~p"/sources/#{media_item.source_id}"}> - <%= StringUtils.truncate(media_item.source.custom_name, 35) %> - - - +