profile/tag_change: show total affected image count

This commit is contained in:
prg 2024-04-28 19:41:21 +02:00 committed by Liam
parent ca9cb3a50e
commit 33a95bc7e6
2 changed files with 14 additions and 2 deletions

View file

@ -14,7 +14,7 @@ defmodule PhilomenaWeb.Profile.TagChangeController do
def index(conn, params) do
user = conn.assigns.user
tag_changes =
common_query =
TagChange
|> join(:inner, [tc], i in Image, on: tc.image_id == i.id)
|> only_tag_join(params)
@ -24,10 +24,18 @@ defmodule PhilomenaWeb.Profile.TagChangeController do
)
|> added_filter(params)
|> only_tag_filter(params)
tag_changes =
common_query
|> preload([:tag, :user, image: [:user, :sources, tags: :aliases]])
|> order_by(desc: :id)
|> Repo.paginate(conn.assigns.scrivener)
image_count =
common_query
|> select([_, i], count(i.id, :distinct))
|> Repo.one()
# params.permit(:added, :only_tag) ...
pagination_params =
[added: conn.params["added"], only_tag: conn.params["only_tag"]]
@ -37,7 +45,8 @@ defmodule PhilomenaWeb.Profile.TagChangeController do
title: "Tag Changes for User `#{user.name}'",
user: user,
tag_changes: tag_changes,
pagination_params: pagination_params
pagination_params: pagination_params,
image_count: image_count
)
end

View file

@ -17,3 +17,6 @@ h1
= link "All", to: Routes.profile_tag_change_path(@conn, :index, @user, Keyword.delete(@pagination_params, :added))
= render PhilomenaWeb.TagChangeView, "index.html", conn: @conn, tag_changes: @tag_changes, pagination: pagination
' Total affected images:
= @image_count