From 8689b662681820ad8866c9ae2b22ba1022926085 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Mon, 2 Sep 2019 00:43:45 -0500 Subject: fix tag timeline media prefetching, remove `limit_params` from prefetch queries --- app/controllers/api/v1/timelines/public_controller.rb | 7 +++---- app/controllers/api/v1/timelines/tag_controller.rb | 13 +++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'app/controllers/api') 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], -- cgit