0
0
Fork 0

Fix #16 - Optimize n+1 queries when checking reblogged/favourited values for status lists in API

This commit is contained in:
Eugen Rochko 2016-10-16 18:57:54 +02:00
parent 1de2833f30
commit de1f3aab86
8 changed files with 23 additions and 10 deletions

View file

@ -10,6 +10,7 @@ class Api::V1::StatusesController < ApiController
@status = Status.find(params[:id])
@ancestors = @status.ancestors
@descendants = @status.descendants
set_maps([@status] + @ancestors + @descendants)
end
def create
@ -46,16 +47,19 @@ class Api::V1::StatusesController < ApiController
def home
@statuses = Feed.new(:home, current_user.account).get(20, params[:max_id], params[:since_id]).to_a
set_maps(@statuses)
render action: :index
end
def mentions
@statuses = Feed.new(:mentions, current_user.account).get(20, params[:max_id], params[:since_id]).to_a
set_maps(@statuses)
render action: :index
end
def public
@statuses = Status.as_public_timeline(current_user.account).paginate_by_max_id(20, params[:max_id], params[:since_id]).to_a
set_maps(@statuses)
render action: :index
end
end