Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed May 5, 2024
2 parents 89100cc + 5b83658 commit 9754668
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/philomena_web/controllers/profile/tag_change_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"]]
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9754668

Please sign in to comment.