chore: copy changes from main

rpp-main
Nelson Jovel 2 years ago
parent 6fe565b636
commit fdc4c49bf0

@ -95,6 +95,7 @@ class SurveyItemValues
dese_id = value_from(pattern: /Dese\s*ID/i) dese_id = value_from(pattern: /Dese\s*ID/i)
dese_id ||= value_from(pattern: /^School$/i) dese_id ||= value_from(pattern: /^School$/i)
dese_id ||= value_from(pattern: /School-\s*\w/i) dese_id ||= value_from(pattern: /School-\s*\w/i)
dese_id.to_i dese_id.to_i
end end
end end
@ -168,7 +169,7 @@ class SurveyItemValues
end end
def raw_income def raw_income
@raw_income ||= value_from(pattern: /Low\s*Income|Raw\s*Income|SES-\s*SIS/i) @raw_income ||= value_from(pattern: /Low\s*Income|Raw\s*Income|SES-\s*SIS|EconDisadvantaged/i)
end end
def income def income
@ -184,7 +185,7 @@ class SurveyItemValues
end end
def raw_sped def raw_sped
@raw_sped ||= value_from(pattern: /Special\s*Ed\s*Status|Raw\s*SpEd|SpEd-\s*SIS/i) @raw_sped ||= value_from(pattern: /Special\s*Ed\s*Status|Raw\s*SpEd|SpEd-\s*SIS|SPED/i)
end end
def sped def sped
@ -193,12 +194,12 @@ class SurveyItemValues
def value_from(pattern:) def value_from(pattern:)
output = nil output = nil
matches = headers matches = headers.select do |header|
.select { |header| pattern.match(header) } pattern.match(header)
.map { |item| item.delete("\n") } end.map { |item| item.delete("\n") }
output = matches.find do |match| matches.each do |match|
row[match]&.strip == nil? output ||= row[match]&.strip
end end
return nil if output&.match?(%r{^#*N/*A$}i) || output.blank? return nil if output&.match?(%r{^#*N/*A$}i) || output.blank?
@ -310,3 +311,4 @@ class SurveyItemValues
end end
end end
end end

Loading…
Cancel
Save