From 43ee70a2def588d0b1f146984c15f7bba1bad03b Mon Sep 17 00:00:00 2001 From: walshyb Date: Fri, 10 Jan 2025 14:11:38 -0500 Subject: [PATCH] Refactor to use not_private scope to remove extra query --- app/controllers/bookmarks_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb index db1a57c1de..fb21c68f3c 100644 --- a/app/controllers/bookmarks_controller.rb +++ b/app/controllers/bookmarks_controller.rb @@ -61,9 +61,8 @@ def search def index if @bookmarkable access_denied unless logged_in_as_admin? || @bookmarkable.visible? - @bookmarks = @bookmarkable.bookmarks.is_public - @bookmarks += @bookmarkable.bookmarks.where(hidden_by_admin: true) if logged_in_as_admin? - @bookmarks = @bookmarks.order_by_created_at.paginate(page: params[:page], per_page: ArchiveConfig.ITEMS_PER_PAGE) + @bookmarks = @bookmarkable.bookmarks.not_private.order_by_created_at.paginate(page: params[:page], per_page: ArchiveConfig.ITEMS_PER_PAGE) + @bookmarks = @bookmarks.filter { |bookmark| !bookmark.hidden_by_admin } unless logged_in_as_admin? else base_options = { show_private: (@user.present? && @user == current_user),