modqueue: optimize sql queries.
* Include appeals and flags. * Avoid an existence query for pools. * Avoid a query checking if the user has previously approved the post. This is a rare condition and it will be prevented anyway if the user tries to reapprove the post.
This commit is contained in:
@@ -10,10 +10,7 @@ module Moderator
|
||||
cookies.permanent["mq_per_page"] = search_params[:per_page]
|
||||
end
|
||||
|
||||
::Post.without_timeout do
|
||||
@posts = ::Post.includes(:disapprovals, :uploader).order("posts.id asc").pending_or_flagged.available_for_moderation(search_params[:hidden]).tag_match(search_params[:tags]).paginate(params[:page], :limit => per_page)
|
||||
@posts.each # hack to force rails to eager load
|
||||
end
|
||||
@posts = ::Post.includes(:appeals, :disapprovals, :uploader, flags: [:creator]).reorder(id: :asc).pending_or_flagged.available_for_moderation(search_params[:hidden]).tag_match(search_params[:tags]).paginate(params[:page], :limit => per_page)
|
||||
respond_with(@posts)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user