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