diff options
author | Starfall <us@starfall.systems> | 2020-08-31 12:28:25 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2020-08-31 12:28:25 -0500 |
commit | c5bb91194f0df90ea9c59ea6af1bd985b295fb30 (patch) | |
tree | 47b303b2c64ff1920fb19d01093a08dc9fd20ac8 /app/controllers/api/v1/accounts/statuses_controller.rb | |
parent | 27ee0fc8c4c13c53f81ca3db781b9d0783b877e5 (diff) | |
parent | f715e8b51612820a18fa307e4465eb0c1a088f86 (diff) |
Merge branch 'glitch' into main
Diffstat (limited to 'app/controllers/api/v1/accounts/statuses_controller.rb')
-rw-r--r-- | app/controllers/api/v1/accounts/statuses_controller.rb | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb index fe932f93c..67e8c94e9 100644 --- a/app/controllers/api/v1/accounts/statuses_controller.rb +++ b/app/controllers/api/v1/accounts/statuses_controller.rb @@ -22,10 +22,6 @@ class Api::V1::Accounts::StatusesController < Api::BaseController end def cached_account_statuses - cache_collection account_statuses, Status - end - - def account_statuses return Status.none unless user_signed_in? statuses = truthy_param?(:pinned) ? pinned_scope : permitted_account_statuses @@ -35,7 +31,12 @@ class Api::V1::Accounts::StatusesController < Api::BaseController statuses.merge!(no_reblogs_scope) if truthy_param?(:exclude_reblogs) statuses.merge!(hashtag_scope) if params[:tagged].present? - statuses.paginate_by_id(limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id)) + cache_collection_paginated_by_id( + statuses, + Status, + limit_param(DEFAULT_STATUSES_LIMIT), + params_slice(:max_id, :since_id, :min_id) + ) end def permitted_account_statuses @@ -43,17 +44,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController end def only_media_scope - Status.where(id: account_media_status_ids) - end - - def account_media_status_ids - # `SELECT DISTINCT id, updated_at` is too slow, so pluck ids at first, and then select id, updated_at with ids. - # Also, Avoid getting slow by not narrowing down by `statuses.account_id`. - # When narrowing down by `statuses.account_id`, `index_statuses_20180106` will be used - # and the table will be joined by `Merge Semi Join`, so the query will be slow. - @account.statuses.joins(:media_attachments).merge(@account.media_attachments).permitted_for(@account, current_account) - .paginate_by_max_id(limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id]) - .reorder(id: :desc).distinct(:id).pluck(:id) + Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id) end def pinned_scope |