From e8e9a857414391a9522a0f9d02be3fb3c3dcd8f0 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 11 Jul 2022 09:44:14 +0100 Subject: [PATCH] extract TYPE_OF_UNIT_MAP --- .../derived_variables/case_log_variables.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/derived_variables/case_log_variables.rb b/app/models/derived_variables/case_log_variables.rb index c12e14e46..e5325bd1c 100644 --- a/app/models/derived_variables/case_log_variables.rb +++ b/app/models/derived_variables/case_log_variables.rb @@ -1,5 +1,13 @@ module DerivedVariables::CaseLogVariables RENT_TYPE_MAPPING = { 0 => 1, 1 => 2, 2 => 2, 3 => 3, 4 => 3, 5 => 3 }.freeze + TYPE_OF_UNIT_MAP = { + "Self-contained flat or bedsit" => 1, + "Self-contained flat or bedsit with common facilities" => 2, + "Shared flat" => 3, + "Shared house or hostel" => 4, + "Bungalow" => 5, + "Self-contained house" => 6, +}.freeze def supported_housing_schemes_enabled? FeatureToggle.supported_housing_schemes_enabled? @@ -75,15 +83,7 @@ module DerivedVariables::CaseLogVariables if location self.la = location.county self.postcode_full = location.postcode - type_of_unit_map = { - "Self-contained flat or bedsit" => 1, - "Self-contained flat or bedsit with common facilities" => 2, - "Shared flat" => 3, - "Shared house or hostel" => 4, - "Bungalow" => 5, - "Self-contained house" => 6, - } - self.unittype_sh = type_of_unit_map[location.type_of_unit] + self.unittype_sh = TYPE_OF_UNIT_MAP[location.type_of_unit] self.builtype = form.questions.find { |x| x.id == "builtype" }.answer_options.select { |_key, value| value["value"] == location.type_of_building }.keys.first wheelchair_adaptation_map = { 1 => 1, 0 => 2 } self.wchair = wheelchair_adaptation_map[location.wheelchair_adaptation.to_i]