From 7798178cbf136823898980c67e5262d1a78fda2d Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:01:34 +0100 Subject: [PATCH] Less loops (#711) --- app/models/form/setup/questions/location_id.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/form/setup/questions/location_id.rb b/app/models/form/setup/questions/location_id.rb index ccdf97097..fc6e421e1 100644 --- a/app/models/form/setup/questions/location_id.rb +++ b/app/models/form/setup/questions/location_id.rb @@ -22,8 +22,8 @@ class Form::Setup::Questions::LocationId < ::Form::Question def displayed_answer_options(case_log) return {} unless case_log.scheme - scheme_location_ids = Location.where(scheme_id: case_log.scheme.id).map(&:id).map(&:to_s) - answer_options.select { |k, _v| scheme_location_ids.include?(k) } + scheme_location_ids = case_log.scheme.locations.pluck(:id) + answer_options.select { |k, _v| scheme_location_ids.include?(k.to_i) } end def hidden_in_check_answers?(case_log, _current_user = nil)