mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 14:17:59 +01:00
profile/tag_change: show total affected image count (#248)
* profile/tag_change: show total affected image count * Incorporate count into block header --------- Co-authored-by: prg <prg@lacunae.de>
This commit is contained in:
parent
ca9cb3a50e
commit
5b836580e1
2 changed files with 17 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -16,4 +16,10 @@ h1
|
|||
= link "Added", to: Routes.profile_tag_change_path(@conn, :index, @user, Keyword.merge(@pagination_params, added: 1))
|
||||
= link "All", to: Routes.profile_tag_change_path(@conn, :index, @user, Keyword.delete(@pagination_params, :added))
|
||||
|
||||
.block__header.block__header--light
|
||||
span.block__header__title.page__info
|
||||
' Listing changes for
|
||||
=> @image_count
|
||||
= pluralize("image", "images", @image_count)
|
||||
|
||||
= render PhilomenaWeb.TagChangeView, "index.html", conn: @conn, tag_changes: @tag_changes, pagination: pagination
|
||||
|
|
Loading…
Reference in a new issue