PERF: Avoid fetching a bunch of ids in polls updater.

This commit is contained in:
Guo Xiang Tan 2018-03-07 14:18:56 +08:00
parent 3045c589f6
commit d02e2cbcca
1 changed files with 1 additions and 1 deletions

View File

@ -28,7 +28,7 @@ module DiscoursePoll
end
# deal with option changes
if User.staff.pluck(:id).include?(post.last_editor_id)
if User.staff.where(id: post.last_editor_id).exists?
# staff can only edit options
polls.each_key do |poll_name|
if polls[poll_name]["options"].size != previous_polls[poll_name]["options"].size && previous_polls[poll_name]["voters"].to_i > 0