Skip to content

Commit

Permalink
Eagerly load statuses with the main query in Api::V1::BookmarksContro…
Browse files Browse the repository at this point in the history
…ller (#14674)

This is same with commit 552e886 except
that it was for Api::V1::FavouritesController while this is for
Api::V1::BookmarksController.
  • Loading branch information
akihikodaki committed Aug 28, 2020
1 parent e26e7a1 commit b63ede5
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/controllers/api/v1/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ def load_statuses
end

def cached_bookmarks
cache_collection(
Status.reorder(nil).joins(:bookmarks).merge(results),
Status
)
cache_collection(results.map(&:status), Status)
end

def results
@_results ||= account_bookmarks.paginate_by_id(
@_results ||= account_bookmarks.eager_load(:status).paginate_by_id(
limit_param(DEFAULT_STATUSES_LIMIT),
params_slice(:max_id, :since_id, :min_id)
)
Expand Down

0 comments on commit b63ede5

Please sign in to comment.