diff --git a/lib/philomena_web/controllers/activity_controller.ex b/lib/philomena_web/controllers/activity_controller.ex index 51fde34f..e159b45f 100644 --- a/lib/philomena_web/controllers/activity_controller.ex +++ b/lib/philomena_web/controllers/activity_controller.ex @@ -54,7 +54,7 @@ defmodule PhilomenaWeb.ActivityController do sort: %{posted_at: :desc} }, %{page_number: 1, page_size: 6}, - Comment |> preload([:user, image: [:tags]]) + Comment |> preload([:user, :image]) ) comment_images = Enum.map(comments, & &1.image) @@ -77,7 +77,6 @@ defmodule PhilomenaWeb.ActivityController do |> filter_hidden(user, conn.params["hidden"]) |> order_by([i, f], desc: f.created_at) |> limit(1) - |> preload([:tags]) |> Repo.one() streams = diff --git a/lib/philomena_web/controllers/duplicate_report_controller.ex b/lib/philomena_web/controllers/duplicate_report_controller.ex index 9ef6dbac..705c42d4 100644 --- a/lib/philomena_web/controllers/duplicate_report_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report_controller.ex @@ -27,7 +27,7 @@ defmodule PhilomenaWeb.DuplicateReportController do duplicate_reports = DuplicateReport |> where([d], d.state in ^states) - |> preload([:user, :modifier, image: [:user, :tags], duplicate_of_image: [:user, :tags]]) + |> preload([:user, :modifier, image: [:user], duplicate_of_image: [:user]]) |> order_by(desc: :created_at) |> Repo.paginate(conn.assigns.scrivener) diff --git a/lib/philomena_web/controllers/fingerprint_profile/source_change_controller.ex b/lib/philomena_web/controllers/fingerprint_profile/source_change_controller.ex index 58f98bac..e87c36ce 100644 --- a/lib/philomena_web/controllers/fingerprint_profile/source_change_controller.ex +++ b/lib/philomena_web/controllers/fingerprint_profile/source_change_controller.ex @@ -13,7 +13,7 @@ defmodule PhilomenaWeb.FingerprintProfile.SourceChangeController do SourceChange |> where(fingerprint: ^fingerprint) |> order_by(desc: :created_at) - |> preload([:user, image: [:user, :tags]]) + |> preload([:user, image: [:user]]) |> Repo.paginate(conn.assigns.scrivener) spoilers = diff --git a/lib/philomena_web/controllers/fingerprint_profile/tag_change_controller.ex b/lib/philomena_web/controllers/fingerprint_profile/tag_change_controller.ex index b3335ec5..56c73681 100644 --- a/lib/philomena_web/controllers/fingerprint_profile/tag_change_controller.ex +++ b/lib/philomena_web/controllers/fingerprint_profile/tag_change_controller.ex @@ -13,7 +13,7 @@ defmodule PhilomenaWeb.FingerprintProfile.TagChangeController do TagChange |> where(fingerprint: ^fingerprint) |> added_filter(params) - |> preload([:tag, :user, image: [:user, :tags]]) + |> preload([:tag, :user, image: [:user]]) |> 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 75f7b2fb..9cae0009 100644 --- a/lib/philomena_web/controllers/gallery_controller.ex +++ b/lib/philomena_web/controllers/gallery_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.GalleryController do plug :load_and_authorize_resource, model: Gallery, except: [:index], - preload: [:creator, thumbnail: :tags] + preload: [:creator, :thumbnail] def index(conn, params) do galleries = @@ -31,7 +31,7 @@ defmodule PhilomenaWeb.GalleryController do sort: parse_sort(params) }, conn.assigns.pagination, - Gallery |> preload([:creator, thumbnail: :tags]) + Gallery |> preload([:creator, :thumbnail]) ) spoilers = diff --git a/lib/philomena_web/controllers/image/comment_controller.ex b/lib/philomena_web/controllers/image/comment_controller.ex index 2d89f812..943e7344 100644 --- a/lib/philomena_web/controllers/image/comment_controller.ex +++ b/lib/philomena_web/controllers/image/comment_controller.ex @@ -23,8 +23,7 @@ defmodule PhilomenaWeb.Image.CommentController do plug :load_and_authorize_resource, model: Image, id_name: "image_id", - persisted: true, - preload: [:tags] + persisted: true plug :verify_authorized when action in [:show] diff --git a/lib/philomena_web/controllers/image/reporting_controller.ex b/lib/philomena_web/controllers/image/reporting_controller.ex index cd0ffb21..393f1e72 100644 --- a/lib/philomena_web/controllers/image/reporting_controller.ex +++ b/lib/philomena_web/controllers/image/reporting_controller.ex @@ -11,15 +11,14 @@ defmodule PhilomenaWeb.Image.ReportingController do plug :load_and_authorize_resource, model: Image, id_name: "image_id", - persisted: true, - preload: [:tags] + persisted: true def show(conn, _params) do image = conn.assigns.image dupe_reports = DuplicateReport - |> preload([:user, :modifier, image: [:user, :tags], duplicate_of_image: [:user, :tags]]) + |> preload([:user, :modifier, image: [:user], duplicate_of_image: [:user]]) |> 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_change_controller.ex b/lib/philomena_web/controllers/image/source_change_controller.ex index 88770c39..071f28ca 100644 --- a/lib/philomena_web/controllers/image/source_change_controller.ex +++ b/lib/philomena_web/controllers/image/source_change_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.SourceChangeController do source_changes = SourceChange |> where(image_id: ^image.id) - |> preload([:user, image: [:user, :tags]]) + |> preload([:user, image: [:user]]) |> order_by(desc: :created_at) |> Repo.paginate(conn.assigns.scrivener) diff --git a/lib/philomena_web/controllers/image/tag_change_controller.ex b/lib/philomena_web/controllers/image/tag_change_controller.ex index 7774c61c..72b7ce32 100644 --- a/lib/philomena_web/controllers/image/tag_change_controller.ex +++ b/lib/philomena_web/controllers/image/tag_change_controller.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do TagChange |> where(image_id: ^image.id) |> added_filter(params) - |> preload([:tag, :user, image: [:user, :tags]]) + |> preload([:tag, :user, image: [:user]]) |> order_by(desc: :created_at) |> Repo.paginate(conn.assigns.scrivener) diff --git a/lib/philomena_web/controllers/ip_profile/source_change_controller.ex b/lib/philomena_web/controllers/ip_profile/source_change_controller.ex index bb357192..967d3ada 100644 --- a/lib/philomena_web/controllers/ip_profile/source_change_controller.ex +++ b/lib/philomena_web/controllers/ip_profile/source_change_controller.ex @@ -15,7 +15,7 @@ defmodule PhilomenaWeb.IpProfile.SourceChangeController do SourceChange |> where(ip: ^ip) |> order_by(desc: :created_at) - |> preload([:user, image: [:user, :tags]]) + |> preload([:user, image: [:user]]) |> Repo.paginate(conn.assigns.scrivener) spoilers = diff --git a/lib/philomena_web/controllers/ip_profile/tag_change_controller.ex b/lib/philomena_web/controllers/ip_profile/tag_change_controller.ex index 0532c644..c8dd070d 100644 --- a/lib/philomena_web/controllers/ip_profile/tag_change_controller.ex +++ b/lib/philomena_web/controllers/ip_profile/tag_change_controller.ex @@ -15,7 +15,7 @@ defmodule PhilomenaWeb.IpProfile.TagChangeController do TagChange |> where(ip: ^ip) |> added_filter(params) - |> preload([:tag, :user, image: [:user, :tags]]) + |> preload([:tag, :user, image: [:user]]) |> order_by(desc: :created_at) |> Repo.paginate(conn.assigns.scrivener) diff --git a/lib/philomena_web/controllers/profile/source_change_controller.ex b/lib/philomena_web/controllers/profile/source_change_controller.ex index 0c6097c5..ccaaa9eb 100644 --- a/lib/philomena_web/controllers/profile/source_change_controller.ex +++ b/lib/philomena_web/controllers/profile/source_change_controller.ex @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Profile.SourceChangeController do [sc, i], sc.user_id == ^user.id and not (i.user_id == ^user.id and i.anonymous == true) ) - |> preload([:user, image: [:user, :tags]]) + |> preload([:user, image: [:user]]) |> order_by(desc: :created_at) |> Repo.paginate(conn.assigns.scrivener) diff --git a/lib/philomena_web/controllers/profile/tag_change_controller.ex b/lib/philomena_web/controllers/profile/tag_change_controller.ex index 70964e60..818b300d 100644 --- a/lib/philomena_web/controllers/profile/tag_change_controller.ex +++ b/lib/philomena_web/controllers/profile/tag_change_controller.ex @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Profile.TagChangeController do tc.user_id == ^user.id and not (i.user_id == ^user.id and i.anonymous == true) ) |> added_filter(params) - |> preload([:tag, :user, image: [:user, :tags]]) + |> preload([:tag, :user, image: [:user]]) |> order_by(desc: :created_at) |> Repo.paginate(conn.assigns.scrivener) diff --git a/lib/philomena_web/controllers/profile_controller.ex b/lib/philomena_web/controllers/profile_controller.ex index f6403d8c..c0faa64a 100644 --- a/lib/philomena_web/controllers/profile_controller.ex +++ b/lib/philomena_web/controllers/profile_controller.ex @@ -28,7 +28,7 @@ defmodule PhilomenaWeb.ProfileController do awards: [:badge, :awarded_by], public_links: :tag, verified_links: :tag, - commission: [sheet_image: :tags, items: [example_image: :tags]] + commission: [:sheet_image, items: :example_image] ] plug :set_admin_metadata @@ -93,7 +93,7 @@ defmodule PhilomenaWeb.ProfileController do sort: %{posted_at: :desc} }, %{page_size: 3}, - Comment |> preload(user: [awards: :badge], image: :tags) + Comment |> preload([:image, user: [awards: :badge]]) ) |> Enum.filter(&Canada.Can.can?(current_user, :show, &1.image)) @@ -132,7 +132,7 @@ defmodule PhilomenaWeb.ProfileController do recent_galleries = Gallery |> where(creator_id: ^user.id) - |> preload([:creator, thumbnail: :tags]) + |> preload([:creator, :thumbnail]) |> limit(4) |> Repo.all() diff --git a/lib/philomena_web/controllers/tag/tag_change_controller.ex b/lib/philomena_web/controllers/tag/tag_change_controller.ex index 05ceb9d5..fdde6db4 100644 --- a/lib/philomena_web/controllers/tag/tag_change_controller.ex +++ b/lib/philomena_web/controllers/tag/tag_change_controller.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Tag.TagChangeController do TagChange |> where(tag_id: ^tag.id) |> added_filter(params) - |> preload([:tag, :user, image: [:user, :tags]]) + |> preload([:tag, :user, image: [:user]]) |> order_by(desc: :created_at) |> Repo.paginate(conn.assigns.scrivener) diff --git a/lib/philomena_web/image_loader.ex b/lib/philomena_web/image_loader.ex index e119e6d2..ca354d4e 100644 --- a/lib/philomena_web/image_loader.ex +++ b/lib/philomena_web/image_loader.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.ImageLoader do def query(conn, body, options \\ []) do pagination = Keyword.get(options, :pagination, conn.assigns.image_pagination) - queryable = Keyword.get(options, :queryable, Image |> preload(:tags)) + queryable = Keyword.get(options, :queryable, Image) sorts = Keyword.get(options, :sorts, &ImageSorter.parse_sort(conn.params, &1)) tags = diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index e20a69d9..829c9dd4 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -7,11 +7,14 @@ defmodule PhilomenaWeb.ImageView do def show_vote_counts?(_user), do: true def title_text(image) do - tags = Tag.display_order(image.tags) |> Enum.map_join(", ", & &1.name) + tags = truncate(image.tag_list_cache) "Size: #{image.image_width}x#{image.image_height} | Tagged: #{tags}" end + def truncate(<>), do: string <> "..." + def truncate(string), do: string + # this is a bit ridiculous def render_intent(_conn, %{thumbnails_generated: false}, _size), do: :not_rendered