about summary refs log tree commit diff
path: root/app/controllers/api
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-09-02 00:43:45 -0500
committermultiple creatures <dev@multiple-creature.party>2019-09-02 00:43:45 -0500
commit8689b662681820ad8866c9ae2b22ba1022926085 (patch)
tree5f265b578264183782be697002b51e4b1a2ade46 /app/controllers/api
parent2d37586daeb38995933da10c88721d4cc25005e8 (diff)
fix tag timeline media prefetching, remove `limit_params` from prefetch queries
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/timelines/public_controller.rb7
-rw-r--r--app/controllers/api/v1/timelines/tag_controller.rb13
2 files changed, 12 insertions, 8 deletions
diff --git a/app/controllers/api/v1/timelines/public_controller.rb b/app/controllers/api/v1/timelines/public_controller.rb
index 9d226ba5a..e5f38508c 100644
--- a/app/controllers/api/v1/timelines/public_controller.rb
+++ b/app/controllers/api/v1/timelines/public_controller.rb
@@ -23,11 +23,10 @@ class Api::V1::Timelines::PublicController < Api::BaseController
 
   def public_statuses
     ptl = public_timeline_statuses
-    ptl_preload = ptl.paginate_by_id(
-      limit_param(DEFAULT_STATUSES_LIMIT * 2),
+    preload_media(ptl.paginate_by_id(
+      DEFAULT_STATUSES_LIMIT * 2,
       params_slice(:max_id, :since_id, :min_id)
-    )
-    preload_media(ptl_preload)
+    ))
     statuses = ptl.paginate_by_id(
       limit_param(DEFAULT_STATUSES_LIMIT),
       params_slice(:max_id, :since_id, :min_id)
diff --git a/app/controllers/api/v1/timelines/tag_controller.rb b/app/controllers/api/v1/timelines/tag_controller.rb
index 4641d6941..01d1b30b8 100644
--- a/app/controllers/api/v1/timelines/tag_controller.rb
+++ b/app/controllers/api/v1/timelines/tag_controller.rb
@@ -29,9 +29,16 @@ class Api::V1::Timelines::TagController < Api::BaseController
     if @tag.nil?
       []
     elsif @tag.name.in?(['self.bookmarks', '.self.bookmarks'])
-      Status.reorder(nil).joins(:bookmarks).merge(bookmark_results)
+      bookmarks = Status.reorder(nil).joins(:bookmarks).merge(bookmark_results)
+      preload_media(bookmarks)
+      bookmarks
     else
-      statuses = tag_timeline_statuses.paginate_by_id(
+      tag_timeline = tag_timeline_statuses
+      preload_media(tag_timeline.paginate_by_id(
+        DEFAULT_STATUSES_LIMIT * 2,
+        params_slice(:max_id, :since_id, :min_id)
+      ))
+      statuses = tag_timeline.paginate_by_id(
         limit_param(DEFAULT_STATUSES_LIMIT),
         params_slice(:max_id, :since_id, :min_id)
       )
@@ -51,8 +58,6 @@ class Api::V1::Timelines::TagController < Api::BaseController
   end
 
   def bookmark_results
-    bookmarks = account_bookmarks
-    preload_media(bookmarks)
     @_results ||= bookmarks.paginate_by_max_id(
       limit_param(DEFAULT_STATUSES_LIMIT),
       params[:max_id],