mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
format
This commit is contained in:
parent
39fe2cbd55
commit
7f348ff5b5
10 changed files with 54 additions and 14 deletions
|
@ -76,7 +76,7 @@ defmodule PhilomenaWeb.ActivityController do
|
|||
|> filter_hidden(user, conn.params["hidden"])
|
||||
|> order_by([i, f], desc: f.created_at)
|
||||
|> limit(1)
|
||||
|> preload([tags: :aliases])
|
||||
|> preload(tags: :aliases)
|
||||
|> Repo.one()
|
||||
|
||||
streams =
|
||||
|
@ -144,7 +144,11 @@ defmodule PhilomenaWeb.ActivityController do
|
|||
responses =
|
||||
Elasticsearch.msearch_records(
|
||||
[images, top_scoring, comments],
|
||||
[preload(Image, tags: :aliases), preload(Image, tags: :aliases), preload(Comment, [:user, image: [tags: :aliases]])]
|
||||
[
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Comment, [:user, image: [tags: :aliases]])
|
||||
]
|
||||
)
|
||||
|
||||
responses ++ [nil]
|
||||
|
|
|
@ -26,7 +26,12 @@ defmodule PhilomenaWeb.DuplicateReportController do
|
|||
duplicate_reports =
|
||||
DuplicateReport
|
||||
|> where([d], d.state in ^states)
|
||||
|> preload([:user, :modifier, image: [:user, tags: :aliases], duplicate_of_image: [:user, tags: :aliases]])
|
||||
|> preload([
|
||||
:user,
|
||||
:modifier,
|
||||
image: [:user, tags: :aliases],
|
||||
duplicate_of_image: [:user, tags: :aliases]
|
||||
])
|
||||
|> order_by(desc: :created_at)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
|
|
|
@ -62,7 +62,11 @@ defmodule PhilomenaWeb.GalleryController do
|
|||
[images, gallery_prev, gallery_next] =
|
||||
Elasticsearch.msearch_records_with_hits(
|
||||
[images, gallery_prev, gallery_next],
|
||||
[preload(Image, tags: :aliases), preload(Image, tags: :aliases), preload(Image, tags: :aliases)]
|
||||
[
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases)
|
||||
]
|
||||
)
|
||||
|
||||
interactions = Interactions.user_interactions([images, gallery_prev, gallery_next], user)
|
||||
|
|
|
@ -18,7 +18,12 @@ defmodule PhilomenaWeb.Image.ReportingController do
|
|||
|
||||
dupe_reports =
|
||||
DuplicateReport
|
||||
|> preload([:user, :modifier, image: [:user, tags: :aliases], duplicate_of_image: [:user, tags: :aliases]])
|
||||
|> preload([
|
||||
:user,
|
||||
:modifier,
|
||||
image: [:user, tags: :aliases],
|
||||
duplicate_of_image: [:user, tags: :aliases]
|
||||
])
|
||||
|> where([d], d.image_id == ^image.id or d.duplicate_of_image_id == ^image.id)
|
||||
|> Repo.all()
|
||||
|
||||
|
|
|
@ -17,7 +17,11 @@ defmodule PhilomenaWeb.Image.SourceController do
|
|||
plug PhilomenaWeb.CheckCaptchaPlug
|
||||
plug PhilomenaWeb.UserAttributionPlug
|
||||
plug PhilomenaWeb.CanaryMapPlug, update: :edit_metadata
|
||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", preload: [:user, tags: :aliases]
|
||||
|
||||
plug :load_and_authorize_resource,
|
||||
model: Image,
|
||||
id_name: "image_id",
|
||||
preload: [:user, tags: :aliases]
|
||||
|
||||
def update(conn, %{"image" => image_params}) do
|
||||
attributes = conn.assigns.attributes
|
||||
|
|
|
@ -19,7 +19,11 @@ defmodule PhilomenaWeb.Image.TagController do
|
|||
plug PhilomenaWeb.CheckCaptchaPlug
|
||||
plug PhilomenaWeb.UserAttributionPlug
|
||||
plug PhilomenaWeb.CanaryMapPlug, update: :edit_metadata
|
||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", preload: [:user, tags: :aliases]
|
||||
|
||||
plug :load_and_authorize_resource,
|
||||
model: Image,
|
||||
id_name: "image_id",
|
||||
preload: [:user, tags: :aliases]
|
||||
|
||||
def update(conn, %{"image" => image_params}) do
|
||||
attributes = conn.assigns.attributes
|
||||
|
@ -58,7 +62,7 @@ defmodule PhilomenaWeb.Image.TagController do
|
|||
|
||||
image =
|
||||
image
|
||||
|> Repo.preload([tags: :aliases], [force: true])
|
||||
|> Repo.preload([tags: :aliases], force: true)
|
||||
|
||||
changeset = Images.change_image(image)
|
||||
|
||||
|
@ -74,7 +78,7 @@ defmodule PhilomenaWeb.Image.TagController do
|
|||
{:error, :image, changeset, _} ->
|
||||
image =
|
||||
image
|
||||
|> Repo.preload([tags: :aliases], [force: true])
|
||||
|> Repo.preload([tags: :aliases], force: true)
|
||||
|
||||
conn
|
||||
|> put_view(PhilomenaWeb.ImageView)
|
||||
|
|
|
@ -14,7 +14,11 @@ defmodule PhilomenaWeb.Profile.Commission.ItemController do
|
|||
id_field: "slug",
|
||||
preload: [
|
||||
:verified_links,
|
||||
commission: [sheet_image: [tags: :aliases], user: [awards: :badge], items: [example_image: [tags: :aliases]]]
|
||||
commission: [
|
||||
sheet_image: [tags: :aliases],
|
||||
user: [awards: :badge],
|
||||
items: [example_image: [tags: :aliases]]
|
||||
]
|
||||
],
|
||||
persisted: true
|
||||
|
||||
|
|
|
@ -19,7 +19,11 @@ defmodule PhilomenaWeb.Profile.Commission.ReportController do
|
|||
id_field: "slug",
|
||||
preload: [
|
||||
:verified_links,
|
||||
commission: [sheet_image: [tags: :aliases], user: [awards: :badge], items: [example_image: [tags: :aliases]]]
|
||||
commission: [
|
||||
sheet_image: [tags: :aliases],
|
||||
user: [awards: :badge],
|
||||
items: [example_image: [tags: :aliases]]
|
||||
]
|
||||
],
|
||||
persisted: true
|
||||
|
||||
|
|
|
@ -14,7 +14,11 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
|||
id_field: "slug",
|
||||
preload: [
|
||||
:verified_links,
|
||||
commission: [sheet_image: [tags: :aliases], user: [awards: :badge], items: [example_image: [tags: :aliases]]]
|
||||
commission: [
|
||||
sheet_image: [tags: :aliases],
|
||||
user: [awards: :badge],
|
||||
items: [example_image: [tags: :aliases]]
|
||||
]
|
||||
],
|
||||
persisted: true
|
||||
|
||||
|
|
|
@ -129,7 +129,8 @@ defmodule PhilomenaWeb.ImageView do
|
|||
[
|
||||
image_id: image.id,
|
||||
image_tags: Jason.encode!(Enum.map(image.tags, & &1.id)),
|
||||
image_tag_aliases: image.tags |> Enum.flat_map(&([&1] ++ &1.aliases)) |> Enum.map_join(", ", &(&1.name)),
|
||||
image_tag_aliases:
|
||||
image.tags |> Enum.flat_map(&([&1] ++ &1.aliases)) |> Enum.map_join(", ", & &1.name),
|
||||
tag_count: length(image.tags),
|
||||
score: image.score,
|
||||
faves: image.faves_count,
|
||||
|
@ -222,7 +223,8 @@ defmodule PhilomenaWeb.ImageView do
|
|||
def image_filter_data(image) do
|
||||
%{
|
||||
id: image.id,
|
||||
"namespaced_tags.name": image.tags |> Enum.flat_map(&([&1] ++ &1.aliases)) |> Enum.map_join(", ", &(&1.name)),
|
||||
"namespaced_tags.name":
|
||||
image.tags |> Enum.flat_map(&([&1] ++ &1.aliases)) |> Enum.map_join(", ", & &1.name),
|
||||
tag_count: length(image.tags),
|
||||
score: image.score,
|
||||
faves: image.faves_count,
|
||||
|
|
Loading…
Reference in a new issue