diff --git a/lib/philomena_web/controllers/activity_controller.ex b/lib/philomena_web/controllers/activity_controller.ex index d185fac9..2439500f 100644 --- a/lib/philomena_web/controllers/activity_controller.ex +++ b/lib/philomena_web/controllers/activity_controller.ex @@ -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] diff --git a/lib/philomena_web/controllers/duplicate_report_controller.ex b/lib/philomena_web/controllers/duplicate_report_controller.ex index 00ab35bb..bc87711b 100644 --- a/lib/philomena_web/controllers/duplicate_report_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report_controller.ex @@ -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) diff --git a/lib/philomena_web/controllers/gallery_controller.ex b/lib/philomena_web/controllers/gallery_controller.ex index 94dc32c7..764c5e41 100644 --- a/lib/philomena_web/controllers/gallery_controller.ex +++ b/lib/philomena_web/controllers/gallery_controller.ex @@ -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) diff --git a/lib/philomena_web/controllers/image/reporting_controller.ex b/lib/philomena_web/controllers/image/reporting_controller.ex index 67e95114..1968e962 100644 --- a/lib/philomena_web/controllers/image/reporting_controller.ex +++ b/lib/philomena_web/controllers/image/reporting_controller.ex @@ -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() diff --git a/lib/philomena_web/controllers/image/source_controller.ex b/lib/philomena_web/controllers/image/source_controller.ex index 153ba117..f741525c 100644 --- a/lib/philomena_web/controllers/image/source_controller.ex +++ b/lib/philomena_web/controllers/image/source_controller.ex @@ -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 diff --git a/lib/philomena_web/controllers/image/tag_controller.ex b/lib/philomena_web/controllers/image/tag_controller.ex index d009ced4..e21d042f 100644 --- a/lib/philomena_web/controllers/image/tag_controller.ex +++ b/lib/philomena_web/controllers/image/tag_controller.ex @@ -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) diff --git a/lib/philomena_web/controllers/profile/commission/item_controller.ex b/lib/philomena_web/controllers/profile/commission/item_controller.ex index a4f1b7db..3502131d 100644 --- a/lib/philomena_web/controllers/profile/commission/item_controller.ex +++ b/lib/philomena_web/controllers/profile/commission/item_controller.ex @@ -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 diff --git a/lib/philomena_web/controllers/profile/commission/report_controller.ex b/lib/philomena_web/controllers/profile/commission/report_controller.ex index 9ca53b9a..181e0410 100644 --- a/lib/philomena_web/controllers/profile/commission/report_controller.ex +++ b/lib/philomena_web/controllers/profile/commission/report_controller.ex @@ -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 diff --git a/lib/philomena_web/controllers/profile/commission_controller.ex b/lib/philomena_web/controllers/profile/commission_controller.ex index 60f69a93..e677fc4f 100644 --- a/lib/philomena_web/controllers/profile/commission_controller.ex +++ b/lib/philomena_web/controllers/profile/commission_controller.ex @@ -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 diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index f91c6ed4..ce65dc8c 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -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,