diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-16 18:57:54 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-10-16 19:10:16 +0200 |
commit | de1f3aab868f8d18198438c405d0852c58f34e10 (patch) | |
tree | 914ad2285da94197fccaee7b462f3d7013823707 /app/controllers/api/v1/accounts_controller.rb | |
parent | 1de2833f3045d48ab6d696a109a7a71f6a469135 (diff) |
Fix #16 - Optimize n+1 queries when checking reblogged/favourited values for status lists in API
Diffstat (limited to 'app/controllers/api/v1/accounts_controller.rb')
-rw-r--r-- | app/controllers/api/v1/accounts_controller.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 7757fd7f8..2669315e2 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -25,6 +25,7 @@ class Api::V1::AccountsController < ApiController def statuses @statuses = @account.statuses.with_includes.with_counters.paginate_by_max_id(20, params[:max_id], params[:since_id]).to_a + set_maps(@statuses) end def follow @@ -53,7 +54,7 @@ class Api::V1::AccountsController < ApiController def relationships ids = params[:id].is_a?(Enumerable) ? params[:id].map(&:to_i) : [params[:id].to_i] - @accounts = Account.find(ids) + @accounts = Account.where(id: ids).select('id') @following = Account.following_map(ids, current_user.account_id) @followed_by = Account.followed_by_map(ids, current_user.account_id) @blocking = Account.blocking_map(ids, current_user.account_id) |