account for nothing left to moderate

This commit is contained in:
r888888888
2016-09-12 16:20:08 -07:00
parent 11244280d8
commit 76c1712989

View File

@@ -22,8 +22,14 @@ module Moderator
cookies.permanent[:moderated] = Time.now.to_i
::Post.without_timeout do
@posts = ::Post.order("posts.id asc").pending_or_flagged.available_for_moderation(false).reorder("random()").limit(5)
@posts = ::Post.order("posts.id asc").where("false").pending_or_flagged.available_for_moderation(false).reorder("random()").limit(5)
@posts.each # hack to force rails to eager load
if @posts.empty?
flash[:notice] = "Nothing left to moderate!"
redirect_to(params[:return_to] || posts_path)
return
end
end
respond_with(@posts)