From e12ff6f11b510c2b4ab41fa005b236a13f83d892 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 11 Jul 2022 09:12:04 +0100 Subject: [PATCH] only run query for scheme locations size once Co-authored-by: Dushan --- app/models/derived_variables/case_log_variables.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/derived_variables/case_log_variables.rb b/app/models/derived_variables/case_log_variables.rb index 5a638fba2..c12e14e46 100644 --- a/app/models/derived_variables/case_log_variables.rb +++ b/app/models/derived_variables/case_log_variables.rb @@ -8,7 +8,8 @@ module DerivedVariables::CaseLogVariables def scheme_has_multiple_locations? return false unless scheme - scheme.locations.size > 1 + @scheme_locations_count ||= scheme.locations.size + @scheme_locations_count > 1 end def set_derived_fields!