diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-09-15 22:44:56 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-09-15 22:44:56 -0500 |
commit | c80712e1c88734b3604467ab4438f242b3a40ef9 (patch) | |
tree | 403922960ec2e9379811339769ba3194c8c5915f /app/controllers | |
parent | 6695379f081d730afa907f687adf11f3c8d6f041 (diff) |
stop pre-caching media on public, home, direct, & list timelines
Diffstat (limited to 'app/controllers')
4 files changed, 3 insertions, 34 deletions
diff --git a/app/controllers/api/v1/timelines/direct_controller.rb b/app/controllers/api/v1/timelines/direct_controller.rb index 61c12ebf7..d8a76d153 100644 --- a/app/controllers/api/v1/timelines/direct_controller.rb +++ b/app/controllers/api/v1/timelines/direct_controller.rb @@ -9,7 +9,6 @@ class Api::V1::Timelines::DirectController < Api::BaseController def show @statuses = load_statuses - preload_media render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) end @@ -61,9 +60,4 @@ class Api::V1::Timelines::DirectController < Api::BaseController def pagination_since_id @statuses.first.id end - - def preload_media - fetch_ids = @statuses.flat_map { |s| s.media_attachments.select { |m| m.needs_redownload? }.pluck(:id) }.uniq - fetch_ids.each { |m| FetchMediaWorker.perform_async(m) } - end end diff --git a/app/controllers/api/v1/timelines/home_controller.rb b/app/controllers/api/v1/timelines/home_controller.rb index 3e8de92bb..fcd0757f1 100644 --- a/app/controllers/api/v1/timelines/home_controller.rb +++ b/app/controllers/api/v1/timelines/home_controller.rb @@ -27,9 +27,7 @@ class Api::V1::Timelines::HomeController < Api::BaseController end def home_statuses - home_feed = account_home_feed - preload_media(home_feed.get(DEFAULT_STATUSES_LIMIT * 2, params[:max_id], params[:since_id], params[:min_id])) - home_feed.get( + account_home_feed.get( limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id], @@ -68,9 +66,4 @@ class Api::V1::Timelines::HomeController < Api::BaseController def regeneration_in_progress? Redis.current.exists("account:#{current_account.id}:regeneration") end - - def preload_media(statuses) - fetch_ids = statuses.flat_map { |s| s.media_attachments.select { |m| m.needs_redownload? }.pluck(:id) }.uniq - fetch_ids.each { |m| FetchMediaWorker.perform_async(m) } - end end diff --git a/app/controllers/api/v1/timelines/list_controller.rb b/app/controllers/api/v1/timelines/list_controller.rb index 59a1eb798..a15eae468 100644 --- a/app/controllers/api/v1/timelines/list_controller.rb +++ b/app/controllers/api/v1/timelines/list_controller.rb @@ -29,9 +29,7 @@ class Api::V1::Timelines::ListController < Api::BaseController end def list_statuses - feed = list_feed - preload_media(feed.get(DEFAULT_STATUSES_LIMIT * 2, params[:max_id], params[:since_id], params[:min_id])) - feed.get( + list_feed.get( limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id], @@ -66,9 +64,4 @@ class Api::V1::Timelines::ListController < Api::BaseController def pagination_since_id @statuses.first.id end - - def preload_media(statuses) - fetch_ids = statuses.flat_map { |s| s.media_attachments.select { |m| m.needs_redownload? }.pluck(:id) }.uniq - fetch_ids.each { |m| FetchMediaWorker.perform_async(m) } - end end diff --git a/app/controllers/api/v1/timelines/public_controller.rb b/app/controllers/api/v1/timelines/public_controller.rb index e5f38508c..9c3f6c0a8 100644 --- a/app/controllers/api/v1/timelines/public_controller.rb +++ b/app/controllers/api/v1/timelines/public_controller.rb @@ -22,12 +22,7 @@ class Api::V1::Timelines::PublicController < Api::BaseController end def public_statuses - ptl = public_timeline_statuses - preload_media(ptl.paginate_by_id( - DEFAULT_STATUSES_LIMIT * 2, - params_slice(:max_id, :since_id, :min_id) - )) - statuses = ptl.paginate_by_id( + statuses = public_timeline_statuses.paginate_by_id( limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id) ) @@ -68,10 +63,4 @@ class Api::V1::Timelines::PublicController < Api::BaseController def pagination_since_id @statuses.first.id end - - def preload_media(statuses) - status_ids = statuses.joins(:media_attachments).distinct(:id).select(:id).reorder(nil) - fetch_ids = MediaAttachment.where(status_id: status_ids, file_updated_at: nil).reject { |m| m.blocked? }.pluck(:id) - fetch_ids.each { |m| FetchMediaWorker.perform_async(m) } - end end |