mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 13:38:18 -08:00
feat: Update demographics file with housing statuses. Create housing class. Update survey_item_values.rb to parse housing info. Update cleaner to output housing info.
This commit is contained in:
parent
b5b4c3b9a6
commit
3a5a368a35
9 changed files with 66 additions and 14 deletions
17
app/models/housing.rb
Normal file
17
app/models/housing.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class Housing < ApplicationRecord
|
||||
def self.to_designation(housing)
|
||||
return "Unknown" if housing.blank?
|
||||
|
||||
housing = housing
|
||||
case housing
|
||||
in /^1$/i
|
||||
"Own"
|
||||
in /^2$/i
|
||||
"Rent"
|
||||
in /^99$|^100$/i
|
||||
"Unknown"
|
||||
else
|
||||
"Unknown"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -65,7 +65,7 @@ class Cleaner
|
|||
.filter { |header| header.start_with? "s-" }
|
||||
.count > 0
|
||||
|
||||
has_grade_header = headers.filter(&:present?).find {|header| header.match?(/grade/i) }.present?
|
||||
has_grade_header = headers.filter(&:present?).find { |header| header.match?(/grade/i) }.present?
|
||||
if is_student_survey && has_grade_header == false
|
||||
puts "could not find the Grade header. Stopping execution"
|
||||
exit
|
||||
|
|
@ -79,7 +79,7 @@ class Cleaner
|
|||
|
||||
headers = headers.to_set
|
||||
headers = headers.merge(Set.new(["Raw Income", "Income", "Raw ELL", "ELL", "Raw SpEd", "SpEd", "Progress Count",
|
||||
"Race", "Gender"])).to_a
|
||||
"Race", "Gender", "Raw Housing Status", "Housing Status"])).to_a
|
||||
filtered_headers = include_all_headers(headers:)
|
||||
filtered_headers = remove_unwanted_headers(headers: filtered_headers)
|
||||
log_headers = (filtered_headers + ["Valid Duration?", "Valid Progress?", "Valid Grade?",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ class DemographicLoader
|
|||
create_from_column(column: "Income", row:, model: Income)
|
||||
create_from_column(column: "ELL", row:, model: Ell)
|
||||
create_from_column(column: "Special Ed Status", row:, model: Sped)
|
||||
create_from_column(column: "Housing", row:, model: Housing)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ class SurveyItemValues
|
|||
row["Progress Count"] = progress
|
||||
row["Race"] ||= races.join(",")
|
||||
row["Gender"] ||= gender
|
||||
row["Raw Housing Status"] = raw_housing
|
||||
row["Housing Status"] = housing
|
||||
|
||||
copy_data_to_main_column(main: /Race/i, secondary: /Race Secondary|Race-1/i)
|
||||
copy_data_to_main_column(main: /Gender/i, secondary: /Gender Secondary|Gender-1/i)
|
||||
|
|
@ -195,6 +197,14 @@ class SurveyItemValues
|
|||
@sped ||= Sped.to_designation(raw_sped)
|
||||
end
|
||||
|
||||
def raw_housing
|
||||
@raw_housing ||= value_from(pattern: /Housing/i)
|
||||
end
|
||||
|
||||
def housing
|
||||
@housing ||= Housing.to_designation(raw_housing)
|
||||
end
|
||||
|
||||
def number_of_children
|
||||
@number_of_children ||= value_from(pattern: /Number\s*Of\s*Children/i).to_i
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue