|
|
|
@ -16,7 +16,8 @@ class Api::V1::AccountsController < ApiController
|
|
|
|
|
|
|
|
|
|
def following
|
|
|
|
|
results = Follow.where(account: @account).paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
|
|
|
|
|
@accounts = Account.where(id: results.map(&:target_account_id)).with_counters.to_a
|
|
|
|
|
accounts = Account.where(id: results.map(&:target_account_id)).with_counters.map { |a| [a.id, a] }.to_h
|
|
|
|
|
@accounts = results.map { |f| accounts[f.target_account_id] }
|
|
|
|
|
|
|
|
|
|
next_path = following_api_v1_account_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
|
|
|
|
prev_path = following_api_v1_account_url(since_id: results.first.id) if results.size > 0
|
|
|
|
@ -28,10 +29,11 @@ class Api::V1::AccountsController < ApiController
|
|
|
|
|
|
|
|
|
|
def followers
|
|
|
|
|
results = Follow.where(target_account: @account).paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
|
|
|
|
|
@accounts = Account.where(id: results.map(&:account_id)).with_counters.to_a
|
|
|
|
|
accounts = Account.where(id: results.map(&:account_id)).with_counters.map { |a| [a.id, a] }.to_h
|
|
|
|
|
@accounts = results.map { |f| accounts[f.account_id] }
|
|
|
|
|
|
|
|
|
|
next_path = following_api_v1_account_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
|
|
|
|
prev_path = following_api_v1_account_url(since_id: results.first.id) if results.size > 0
|
|
|
|
|
next_path = followers_api_v1_account_url(max_id: results.last.id) if results.size == DEFAULT_ACCOUNTS_LIMIT
|
|
|
|
|
prev_path = followers_api_v1_account_url(since_id: results.first.id) if results.size > 0
|
|
|
|
|
|
|
|
|
|
set_pagination_headers(next_path, prev_path)
|
|
|
|
|
|
|
|
|
|