duplicate reports fixes

This commit is contained in:
byte[] 2019-11-30 23:58:32 -05:00
parent bec983fdf1
commit 80077786cf
3 changed files with 6 additions and 6 deletions

View file

@ -10,18 +10,18 @@ defmodule PhilomenaWeb.DuplicateReportController do
@valid_states ~W(open rejected accepted claimed)
plug PhilomenaWeb.FilterBannedUsersPlug when action in [:create]
plug :load_resource, model: DuplicateReport, only: [:show], preload: [:user, image: :tags, duplicate_of_image: :tags]
plug :load_resource, model: DuplicateReport, only: [:show], preload: [:image, :duplicate_of_image]
def index(conn, params) do
states =
params["states"]
(params["states"] || ~W(open claimed))
|> wrap()
|> Enum.filter(&Enum.member?(@valid_states, &1))
duplicate_reports =
DuplicateReport
|> where([d], d.state in ^states)
|> preload([:user, image: :tags, duplicate_of_image: :tags])
|> preload([:user, image: [:user, :tags], duplicate_of_image: [:user, :tags]])
|> order_by(desc: :created_at)
|> Repo.paginate(conn.assigns.pagination)

View file

@ -6,7 +6,7 @@
| #
= @image.id
= render PhilomenaWeb.ImageView, "_image_container.html", image: @image, size: @thumb_small, conn: @conn
= render PhilomenaWeb.ImageView, "_image_container.html", image: @image, size: :thumb_small, conn: @conn
p
= @image.image_width

View file

@ -39,8 +39,8 @@ defmodule PhilomenaWeb.DuplicateReportView do
do: duplicate_of_image.image_mime_type == image.image_mime_type
def better_format?(%{image: image, duplicate_of_image: duplicate_of_image}) do
source_index = Enum.find_index(@formats_order, image.image_mime_type) || length(@formats_order) - 1
target_index = Enum.find_index(@formats_order, duplicate_of_image.image_mime_type) || length(@formats_order) - 1
source_index = Enum.find_index(@formats_order, &image.image_mime_type == &1) || length(@formats_order) - 1
target_index = Enum.find_index(@formats_order, &duplicate_of_image.image_mime_type == &1) || length(@formats_order) - 1
target_index < source_index
end