|
|
|
@ -32,12 +32,14 @@ class Api::V1::StatusesController < ApiController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def reblogged_by
|
|
|
|
|
results = @status.reblogs.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id])
|
|
|
|
|
accounts = Account.where(id: results.map(&:account_id)).map { |a| [a.id, a] }.to_h
|
|
|
|
|
@accounts = results.map { |r| accounts[r.account_id] }
|
|
|
|
|
@accounts = Account.includes(statuses: :reblogs)
|
|
|
|
|
.references(statuses: :reblogs)
|
|
|
|
|
.where(statuses: { id: @status.id })
|
|
|
|
|
.merge(@status.reblogs.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]))
|
|
|
|
|
.to_a
|
|
|
|
|
|
|
|
|
|
next_path = reblogged_by_api_v1_status_url(pagination_params(max_id: results.last.id)) if results.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
|
|
|
|
prev_path = reblogged_by_api_v1_status_url(pagination_params(since_id: results.first.id)) unless results.empty?
|
|
|
|
|
next_path = reblogged_by_api_v1_status_url(pagination_params(max_id: @accounts.last.statuses.last.reblogs.last.id)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
|
|
|
|
prev_path = reblogged_by_api_v1_status_url(pagination_params(since_id: @accounts.first.statuses.first.reblogs.first.id)) unless @accounts.empty?
|
|
|
|
|
|
|
|
|
|
set_pagination_headers(next_path, prev_path)
|
|
|
|
|
|
|
|
|
@ -45,12 +47,14 @@ class Api::V1::StatusesController < ApiController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def favourited_by
|
|
|
|
|
results = @status.favourites.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id])
|
|
|
|
|
accounts = Account.where(id: results.map(&:account_id)).map { |a| [a.id, a] }.to_h
|
|
|
|
|
@accounts = results.map { |f| accounts[f.account_id] }
|
|
|
|
|
|
|
|
|
|
next_path = favourited_by_api_v1_status_url(pagination_params(max_id: results.last.id)) if results.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
|
|
|
|
prev_path = favourited_by_api_v1_status_url(pagination_params(since_id: results.first.id)) unless results.empty?
|
|
|
|
|
@accounts = Account.includes(statuses: :favourites)
|
|
|
|
|
.references(statuses: :favourites)
|
|
|
|
|
.where(statuses: { id: @status.id })
|
|
|
|
|
.merge(@status.favourites.paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]))
|
|
|
|
|
.to_a
|
|
|
|
|
|
|
|
|
|
next_path = favourited_by_api_v1_status_url(pagination_params(max_id: @accounts.last.statuses.last.favourites.last.id)) if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
|
|
|
|
prev_path = favourited_by_api_v1_status_url(pagination_params(since_id: @accounts.first.statuses.first.favourites.first.id)) unless @accounts.empty?
|
|
|
|
|
|
|
|
|
|
set_pagination_headers(next_path, prev_path)
|
|
|
|
|
|
|
|
|
|