about summary refs log tree commit diff
path: root/app/controllers/api
diff options
context:
space:
mode:
authorAkihiko Odaki <nekomanma@pixiv.co.jp>2020-08-28 19:30:23 +0900
committerGitHub <noreply@github.com>2020-08-28 12:30:23 +0200
commitb63ede5005d33b52266650ec716d345f166e2df0 (patch)
treed96781fdd23740dcf0ade1d7c8126d949a5b76db /app/controllers/api
parente26e7a1cb5992375eecedbc10ab9bcef4e603a88 (diff)
Eagerly load statuses with the main query in Api::V1::BookmarksController (#14674)
This is same with commit 552e886b648faa2a2229d86c7fd9abc8bb5ff99c except
that it was for Api::V1::FavouritesController while this is for
Api::V1::BookmarksController.
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/bookmarks_controller.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/app/controllers/api/v1/bookmarks_controller.rb b/app/controllers/api/v1/bookmarks_controller.rb
index c15212f0a..5c72f4a1a 100644
--- a/app/controllers/api/v1/bookmarks_controller.rb
+++ b/app/controllers/api/v1/bookmarks_controller.rb
@@ -17,14 +17,11 @@ class Api::V1::BookmarksController < Api::BaseController
   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)
     )