Skip to content

Commit

Permalink
Refactor to use not_private scope to remove extra query
Browse files Browse the repository at this point in the history
  • Loading branch information
walshyb committed Jan 10, 2025
1 parent 5d4dc02 commit 43ee70a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/controllers/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 43ee70a

Please sign in to comment.