]> cat aescling's git repositories - mastodon.git/commitdiff
Eagerly load statuses with the main query in Api::V1::BookmarksController (#14674)
authorAkihiko Odaki <nekomanma@pixiv.co.jp>
Fri, 28 Aug 2020 10:30:23 +0000 (19:30 +0900)
committerGitHub <noreply@github.com>
Fri, 28 Aug 2020 10:30:23 +0000 (12:30 +0200)
This is same with commit 552e886b648faa2a2229d86c7fd9abc8bb5ff99c except
that it was for Api::V1::FavouritesController while this is for
Api::V1::BookmarksController.

app/controllers/api/v1/bookmarks_controller.rb

index c15212f0a91dd4be00891f91dd3ebf0f1d7fa1a8..5c72f4a1a58c9eac9a24478aa5914b047796877c 100644 (file)
@@ -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)
     )