Browse Source

add ethnic_group and ethnic to bulk upload

pull/1148/head
Phil Lee 3 years ago
parent
commit
43b5973180
  1. 25
      app/services/bulk_upload/lettings/row_parser.rb
  2. 2
      spec/services/bulk_upload/lettings/row_parser_spec.rb

25
app/services/bulk_upload/lettings/row_parser.rb

@ -249,6 +249,9 @@ private
age8: %i[field_19],
sex1: %i[field_20],
ethnic_group: %i[field_43],
ethnic: %i[field_43],
}
end
@ -340,9 +343,31 @@ private
attributes["sex1"] = field_20
attributes["ethnic_group"] = ethnic_group_from_ethnic
attributes["ethnic"] = field_43
attributes
end
def ethnic_group_from_ethnic
return nil if field_43.blank?
case field_43
when 1, 2, 3, 18
0
when 4, 5, 6, 7
1
when 8, 9, 10, 11, 15
2
when 12, 13, 14
3
when 16, 19
4
when 17
17
end
end
def scheme
@scheme ||= Scheme.find_by(old_visible_id: field_4)
end

2
spec/services/bulk_upload/lettings/row_parser_spec.rb

@ -80,6 +80,8 @@ RSpec.describe BulkUpload::Lettings::RowParser do
field_19: "10",
field_20: "F",
field_43: "17",
}
end

Loading…
Cancel
Save