From d02e2cbcca9fde4516e30b87d09e975ea87f88b7 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 7 Mar 2018 14:18:56 +0800 Subject: [PATCH] PERF: Avoid fetching a bunch of ids in polls updater. --- plugins/poll/lib/polls_updater.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/poll/lib/polls_updater.rb b/plugins/poll/lib/polls_updater.rb index ec5b250579b..72913c67ab0 100644 --- a/plugins/poll/lib/polls_updater.rb +++ b/plugins/poll/lib/polls_updater.rb @@ -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