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.

main-eol
rebuilt 9 months ago
parent b5b4c3b9a6
commit 3a5a368a35

@ -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

@ -1,11 +1,11 @@
Race Qualtrics Code,Race/Ethnicity,Gender Qualtrics Code,Sex/Gender,Income,ELL,Special Ed Status
1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education
2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education
3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown
4,Hispanic or Latinx,99,Unknown,,,
5,White or Caucasian,,,,,
6,Prefer not to disclose,,,,,
7,Prefer to self-describe,,,,,
8,Middle Eastern,,,,,
99,Race/Ethnicity Not Listed,,,,,
100,Multiracial,,,,,
Race Qualtrics Code,Race/Ethnicity,Gender Qualtrics Code,Sex/Gender,Income,ELL,Special Ed Status,Housing
1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education,Own
2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education,Rent
3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown,Unknown
4,Hispanic or Latinx,99,Unknown,,,,
5,White or Caucasian,,,,,,
6,Prefer not to disclose,,,,,,
7,Prefer to self-describe,,,,,,
8,Middle Eastern,,,,,,
99,Race/Ethnicity Not Listed,,,,,,
100,Multiracial,,,,,,

1 Race Qualtrics Code Race/Ethnicity Gender Qualtrics Code Sex/Gender Income ELL Special Ed Status Housing
2 1 American Indian or Alaskan Native 2 Male Economically Disadvantaged - N ELL Special Education Own
3 2 Asian or Pacific Islander 1 Female Economically Disadvantaged - Y Not ELL Not Special Education Rent
4 3 Black or African American 4 Non-Binary Unknown Unknown Unknown Unknown
5 4 Hispanic or Latinx 99 Unknown
6 5 White or Caucasian
7 6 Prefer not to disclose
8 7 Prefer to self-describe
9 8 Middle Eastern
10 99 Race/Ethnicity Not Listed
11 100 Multiracial

@ -0,0 +1,9 @@
class CreateHousings < ActiveRecord::Migration[8.0]
def change
create_table :housings do |t|
t.string :designation
t.timestamps
end
end
end

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_01_15_011457) do
ActiveRecord::Schema[8.0].define(version: 2025_03_27_205800) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
@ -88,6 +88,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_15_011457) do
t.index ["slug"], name: "index_genders_on_slug", unique: true
end
create_table "housings", force: :cascade do |t|
t.string "designation"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "incomes", force: :cascade do |t|
t.string "designation"
t.datetime "created_at", null: false

@ -1,4 +1,8 @@
FactoryBot.define do
factory :housing do
designation { "MyString" }
end
factory :parent do
response_id { "MyString" }
number_of_children { 1 }

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Housing, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save