mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-02 23:57:59 +01:00
duplicate reports fixes
This commit is contained in:
parent
bec983fdf1
commit
80077786cf
3 changed files with 6 additions and 6 deletions
|
@ -10,18 +10,18 @@ defmodule PhilomenaWeb.DuplicateReportController do
|
||||||
@valid_states ~W(open rejected accepted claimed)
|
@valid_states ~W(open rejected accepted claimed)
|
||||||
|
|
||||||
plug PhilomenaWeb.FilterBannedUsersPlug when action in [:create]
|
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
|
def index(conn, params) do
|
||||||
states =
|
states =
|
||||||
params["states"]
|
(params["states"] || ~W(open claimed))
|
||||||
|> wrap()
|
|> wrap()
|
||||||
|> Enum.filter(&Enum.member?(@valid_states, &1))
|
|> Enum.filter(&Enum.member?(@valid_states, &1))
|
||||||
|
|
||||||
duplicate_reports =
|
duplicate_reports =
|
||||||
DuplicateReport
|
DuplicateReport
|
||||||
|> where([d], d.state in ^states)
|
|> 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)
|
|> order_by(desc: :created_at)
|
||||||
|> Repo.paginate(conn.assigns.pagination)
|
|> Repo.paginate(conn.assigns.pagination)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
| #
|
| #
|
||||||
= @image.id
|
= @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
|
p
|
||||||
= @image.image_width
|
= @image.image_width
|
||||||
|
|
|
@ -39,8 +39,8 @@ defmodule PhilomenaWeb.DuplicateReportView do
|
||||||
do: duplicate_of_image.image_mime_type == image.image_mime_type
|
do: duplicate_of_image.image_mime_type == image.image_mime_type
|
||||||
|
|
||||||
def better_format?(%{image: image, duplicate_of_image: duplicate_of_image}) do
|
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
|
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) || 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
|
target_index < source_index
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue