Browse Source

refactor: combine label mapping

pull/2089/head
natdeanlewissoftwire 2 years ago
parent
commit
541d741b94
  1. 14
      app/services/csv/lettings_log_csv_service.rb

14
app/services/csv/lettings_log_csv_service.rb

@ -183,11 +183,7 @@ module Csv
end end
def get_label(value, attribute, log) def get_label(value, attribute, log)
return LETTYPE_LABELS[value] if attribute == "lettype" return LABELS[attribute][value] if LABELS.key?(attribute)
return IRPRODUCT_LABELS[value] if attribute == "irproduct"
return LAR_LABELS[value] if attribute == "lar"
return NEWPROP_LABELS[value] if attribute == "newprop"
return INCREF_LABELS[value] if attribute == "incref"
return conventional_yes_no_label(value) if CONVENTIONAL_YES_NO_ATTRIBUTES.include?(attribute) return conventional_yes_no_label(value) if CONVENTIONAL_YES_NO_ATTRIBUTES.include?(attribute)
return "Yes" if YES_OR_BLANK_ATTRIBUTES.include?(attribute) && value == 1 return "Yes" if YES_OR_BLANK_ATTRIBUTES.include?(attribute) && value == 1
@ -210,6 +206,14 @@ module Csv
value == 1 ? "Yes" : nil value == 1 ? "Yes" : nil
end end
LABELS = {
"lettype": LETTYPE_LABELS,
"irproduct": IRPRODUCT_LABELS,
"lar": LAR_LABELS,
"newprop": NEWPROP_LABELS,
"incref": INCREF_LABELS,
}.freeze
LETTYPE_LABELS = { LETTYPE_LABELS = {
1 => "Social rent general needs private registered provider", 1 => "Social rent general needs private registered provider",
2 => "Social rent supported housing private registered provider", 2 => "Social rent supported housing private registered provider",

Loading…
Cancel
Save