From 80077786cf6b26bb6ebc95c851f9653576ab94b5 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sat, 30 Nov 2019 23:58:32 -0500 Subject: [PATCH] duplicate reports fixes --- .../controllers/duplicate_report_controller.ex | 6 +++--- .../templates/duplicate_report/_image_cell.html.slime | 2 +- lib/philomena_web/views/duplicate_report_view.ex | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/philomena_web/controllers/duplicate_report_controller.ex b/lib/philomena_web/controllers/duplicate_report_controller.ex index 43c5270f..536faf65 100644 --- a/lib/philomena_web/controllers/duplicate_report_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report_controller.ex @@ -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) diff --git a/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime b/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime index 1937550e..cdd0beaa 100644 --- a/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime +++ b/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime @@ -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 diff --git a/lib/philomena_web/views/duplicate_report_view.ex b/lib/philomena_web/views/duplicate_report_view.ex index ea3af2cc..974f31ab 100644 --- a/lib/philomena_web/views/duplicate_report_view.ex +++ b/lib/philomena_web/views/duplicate_report_view.ex @@ -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