From a258b32b391e9ed0933f10aac8eda347099ad47e Mon Sep 17 00:00:00 2001 From: rebuilt Date: Wed, 25 Jun 2025 11:08:12 -0700 Subject: [PATCH] WIP: create backend for socio-economic-status --- app/models/benefit.rb | 32 ++++++++++ app/models/education.rb | 45 ++++++++++++++ app/models/employment.rb | 39 ++++++++++++ app/models/parent.rb | 4 ++ app/models/report/survey_item_by_grade.rb | 2 - app/services/demographic_loader.rb | 3 + app/services/survey_item_values.rb | 18 ++++++ app/services/survey_responses_data_loader.rb | 19 ++++++ data/demographics.csv | 22 +++---- .../20250624180025_create_employments.rb | 9 +++ .../20250624180041_create_educations.rb | 9 +++ db/migrate/20250624180051_create_benefits.rb | 9 +++ .../20250624180139_add_education_to_parent.rb | 5 ++ .../20250624180155_add_benefits_to_parent.rb | 5 ++ ...20250624230522_create_parent_employment.rb | 10 ++++ db/schema.rb | 37 +++++++++++- spec/factories.rb | 12 ++++ .../test_2020-21_parent_survey_responses.csv | 12 ++-- spec/models/benefit_spec.rb | 5 ++ spec/models/education_spec.rb | 5 ++ spec/models/employment_spec.rb | 5 ++ spec/services/cleaner_spec.rb | 3 - .../survey_responses_data_loader_spec.rb | 59 +++++++++++++++++++ 23 files changed, 346 insertions(+), 23 deletions(-) create mode 100644 app/models/benefit.rb create mode 100644 app/models/education.rb create mode 100644 app/models/employment.rb create mode 100644 db/migrate/20250624180025_create_employments.rb create mode 100644 db/migrate/20250624180041_create_educations.rb create mode 100644 db/migrate/20250624180051_create_benefits.rb create mode 100644 db/migrate/20250624180139_add_education_to_parent.rb create mode 100644 db/migrate/20250624180155_add_benefits_to_parent.rb create mode 100644 db/migrate/20250624230522_create_parent_employment.rb create mode 100644 spec/models/benefit_spec.rb create mode 100644 spec/models/education_spec.rb create mode 100644 spec/models/employment_spec.rb diff --git a/app/models/benefit.rb b/app/models/benefit.rb new file mode 100644 index 00000000..1125eb5a --- /dev/null +++ b/app/models/benefit.rb @@ -0,0 +1,32 @@ +class Benefit < ApplicationRecord + scope :by_designation, -> { all.map { |benefits| [benefits.designation, benefits] }.to_h } + + def self.to_designation(benefits) + return "Unknown" if benefits.blank? or benefits.nil? + + case benefits + in /^1$/i + "Yes" + in /^2$/i + "No" + in /^3$/i + "Unknown" + in /^99$|^100$/i + "Unknown" + else + puts "************************************" + puts "******** ERROR **********" + puts "" + puts "Error parsing Income column. '#{benefits}' is not a known value. Halting execution" + puts "" + puts "************************************" + exit + end + end + + def points + return 1 if designation == "Yes" + + 0 + end +end diff --git a/app/models/education.rb b/app/models/education.rb new file mode 100644 index 00000000..91f31981 --- /dev/null +++ b/app/models/education.rb @@ -0,0 +1,45 @@ +class Education < ApplicationRecord + scope :by_designation, -> { all.map { |education| [education.designation, education] }.to_h } + + def self.to_designation(education) + return "Unknown" if education.blank? or education.nil? + + case education + in /^1$/i + "No formal schooling completed" + in /^2$/i + "Some formal schooling" + in /^3$/i + "High school diploma or GED" + in /^4$/i + "Associates Degree" + in /^5$/i + "Bachelors Degree" + in /^6$/i + "Masters Degree" + in /^7$/i + "Professional Degree" + in /^8$/i + "Doctorate Degree" + in /^99$|^100$/i + "Unknown" + else + puts "************************************" + puts "******** ERROR **********" + puts "" + puts "Error parsing Income column. '#{education}' is not a known value. Halting execution" + puts "" + puts "************************************" + exit + end + end + + def points + higher_level_education = ["Associates Degree", "Bachelors Degree", "Masters Degree", "Professional Degree", "Doctorate Degree"] + if higher_level_education.include?(designation) + 1 + else + 0 + end + end +end diff --git a/app/models/employment.rb b/app/models/employment.rb new file mode 100644 index 00000000..27aa7212 --- /dev/null +++ b/app/models/employment.rb @@ -0,0 +1,39 @@ +class Employment < ApplicationRecord + scope :by_designation, -> { all.map { |employment| [employment.designation, employment] }.to_h } + + def self.to_designation(employment) + return "Unknown" if employment.blank? or employment.nil? + + case employment + in /^1$/i + "Two adults with full-time employment" + in /^2$/i + "One adult with full-time employment" + in /^3$/i + "Two adults with part-time employment" + in /^4$/i + "One adult with part-time employment" + in /^5$/i + "No full-time or part-time employment" + in /^99$|^100$/i + "Unknown" + else + puts "************************************" + puts "******** ERROR **********" + puts "" + puts "Error parsing Income column. '#{employment}' is not a known value. Halting execution" + puts "" + puts "************************************" + exit + end + end + + def points + higher_level_employment = ["Two adults with full-time employment", "One adult with full-time employment"] + if higher_level_employment.include?(designation) + 1 + else + 0 + end + end +end diff --git a/app/models/parent.rb b/app/models/parent.rb index 0c535dff..0a3c9b6e 100644 --- a/app/models/parent.rb +++ b/app/models/parent.rb @@ -1,7 +1,11 @@ class Parent < ApplicationRecord belongs_to :housing, optional: true + belongs_to :education, optional: true + belongs_to :benefit, optional: true + has_many :parent_languages has_and_belongs_to_many :languages, join_table: :parent_languages has_and_belongs_to_many :races, join_table: :parent_races has_and_belongs_to_many :genders, join_table: :parent_genders + has_and_belongs_to_many :employments, join_table: :parent_employments end diff --git a/app/models/report/survey_item_by_grade.rb b/app/models/report/survey_item_by_grade.rb index 27fdbab1..ebf858aa 100644 --- a/app/models/report/survey_item_by_grade.rb +++ b/app/models/report/survey_item_by_grade.rb @@ -67,7 +67,6 @@ module Report row << academic_year.range survey_items.each do |survey_item_id| survey_item = survey_items_by_id[survey_item_id] - byebug if survey_item.nil? if sufficient_survey_items[grade].include? survey_item_id row.append("#{survey_item.survey_item_responses.where(school:, academic_year:, grade:).average(:likert_score).to_f.round(2)}") @@ -87,7 +86,6 @@ module Report row.append(academic_year.range) survey_items.each do |survey_item_id| survey_item = survey_items_by_id[survey_item_id] - byebug if survey_item.nil? # filter out response rate at subcategory level <24.5% for school average subcategory = survey_item.scale.measure.subcategory if ::StudentResponseRateCalculator.new(subcategory:, school:, academic_year:).meets_student_threshold? diff --git a/app/services/demographic_loader.rb b/app/services/demographic_loader.rb index 5c2aa3ce..77a4c66e 100644 --- a/app/services/demographic_loader.rb +++ b/app/services/demographic_loader.rb @@ -10,6 +10,9 @@ class DemographicLoader create_from_column(column: "Special Ed Status", row:, model: Sped) create_from_column(column: "Housing", row:, model: Housing) create_from_column(column: "Language", row:, model: Language) + create_from_column(column: "Employment", row:, model: Employment) + create_from_column(column: "Education", row:, model: Education) + create_from_column(column: "Benefits", row:, model: Benefit) end end diff --git a/app/services/survey_item_values.rb b/app/services/survey_item_values.rb index 001645e7..d89ffff4 100644 --- a/app/services/survey_item_values.rb +++ b/app/services/survey_item_values.rb @@ -102,6 +102,24 @@ class SurveyItemValues @response_id ||= value_from(pattern: /Response\s*ID/i) end + def employments + e = value_from(pattern: /^Employment$/i) + + return [] if e.nil? || e.empty? + + e.split(",").map do |item| + Employment.to_designation(item.strip) + end + end + + def education + Education.to_designation(value_from(pattern: /^Education$/i)&.strip) + end + + def benefits + Benefit.to_designation(value_from(pattern: /^Benefits$/i)&.strip) + end + def dese_id @dese_id ||= begin dese_id = value_from(pattern: /Dese\s*ID/i) diff --git a/app/services/survey_responses_data_loader.rb b/app/services/survey_responses_data_loader.rb index b9b3461d..ea34c9f1 100644 --- a/app/services/survey_responses_data_loader.rb +++ b/app/services/survey_responses_data_loader.rb @@ -78,6 +78,18 @@ class SurveyResponsesDataLoader @speds ||= Sped.by_designation end + def employments + @employments ||= Employment.by_designation + end + + def educations + @educations ||= Education.by_designation + end + + def benefits + @benefits ||= Benefit.by_designation + end + def academic_years @academic_years ||= AcademicYear.all end @@ -110,6 +122,9 @@ class SurveyResponsesDataLoader if row.respondent_type == :parent parent = Parent.find_or_create_by(response_id: row.response_id) parent.number_of_children = row.number_of_children + parent.education = educations[row.education] if row.education.present? + parent.benefits_id = benefits[row.benefits].id if row.benefits.present? + tmp_languages = row.languages.map { |language| languages[language] }.reject(&:nil?) parent.languages.delete_all parent.languages.concat(tmp_languages) @@ -122,6 +137,10 @@ class SurveyResponsesDataLoader tmp_genders = row.genders_of_children.map { |race| genders[race] }.reject(&:nil?) parent.genders.concat(tmp_genders) + parent.employments.delete_all + tmp_employments = row.employments.map { |employment| employments[employment] }.reject(&:nil?) + parent.employments.concat(tmp_employments) + parent.housing = housings[row.housing] if row.housing.present? parent.save end diff --git a/data/demographics.csv b/data/demographics.csv index 9823c81c..55bea742 100644 --- a/data/demographics.csv +++ b/data/demographics.csv @@ -1,11 +1,11 @@ -Race Qualtrics Code,Race/Ethnicity,Gender Qualtrics Code,Sex/Gender,Income,ELL,Special Ed Status,Housing,Language -1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education,Own,English -2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education,Rent,Portuguese -3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown,Unknown,Spanish -4,Hispanic or Latinx,99,Unknown,,,,,Prefer not to disclose -5,White or Caucasian,,,,,,,Prefer to self-describe -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,Language,Employment,Education,Benefits +1,American Indian or Alaskan Native,2,Male,Economically Disadvantaged - N,ELL,Special Education,Own,English,Two adults with full-time employment,No formal schooling completed,Yes +2,Asian or Pacific Islander,1,Female,Economically Disadvantaged - Y,Not ELL,Not Special Education,Rent,Portuguese,One adult with full-time employment,Some formal schooling,No +3,Black or African American,4,Non-Binary,Unknown,Unknown,Unknown,Unknown,Spanish,Two adults with part-time employment,High school diploma or GED,Unknown +4,Hispanic or Latinx,99,Unknown,,,,,Prefer not to disclose,One adult with part-time employment,Associates Degree, +5,White or Caucasian,,,,,,,Prefer to self-describe,No full-time or part-time employment,Bachelors Degree, +6,Prefer not to disclose,,,,,,,,Unknown,Masters Degree, +7,Prefer to self-describe,,,,,,,,,Professional Degree, +8,Middle Eastern,,,,,,,,,Doctoral Degree, +99,Race/Ethnicity Not Listed,,,,,,,,,Unknown, +100,Multiracial,,,,,,,,,, diff --git a/db/migrate/20250624180025_create_employments.rb b/db/migrate/20250624180025_create_employments.rb new file mode 100644 index 00000000..8afd1497 --- /dev/null +++ b/db/migrate/20250624180025_create_employments.rb @@ -0,0 +1,9 @@ +class CreateEmployments < ActiveRecord::Migration[8.0] + def change + create_table :employments do |t| + t.string :designation + + t.timestamps + end + end +end diff --git a/db/migrate/20250624180041_create_educations.rb b/db/migrate/20250624180041_create_educations.rb new file mode 100644 index 00000000..b8651f8a --- /dev/null +++ b/db/migrate/20250624180041_create_educations.rb @@ -0,0 +1,9 @@ +class CreateEducations < ActiveRecord::Migration[8.0] + def change + create_table :educations do |t| + t.string :designation + + t.timestamps + end + end +end diff --git a/db/migrate/20250624180051_create_benefits.rb b/db/migrate/20250624180051_create_benefits.rb new file mode 100644 index 00000000..c44cc60a --- /dev/null +++ b/db/migrate/20250624180051_create_benefits.rb @@ -0,0 +1,9 @@ +class CreateBenefits < ActiveRecord::Migration[8.0] + def change + create_table :benefits do |t| + t.string :designation + + t.timestamps + end + end +end diff --git a/db/migrate/20250624180139_add_education_to_parent.rb b/db/migrate/20250624180139_add_education_to_parent.rb new file mode 100644 index 00000000..0b9e878d --- /dev/null +++ b/db/migrate/20250624180139_add_education_to_parent.rb @@ -0,0 +1,5 @@ +class AddEducationToParent < ActiveRecord::Migration[8.0] + def change + add_reference :parents, :education, foreign_key: true + end +end diff --git a/db/migrate/20250624180155_add_benefits_to_parent.rb b/db/migrate/20250624180155_add_benefits_to_parent.rb new file mode 100644 index 00000000..7343ff16 --- /dev/null +++ b/db/migrate/20250624180155_add_benefits_to_parent.rb @@ -0,0 +1,5 @@ +class AddBenefitsToParent < ActiveRecord::Migration[8.0] + def change + add_reference :parents, :benefits, foreign_key: true + end +end diff --git a/db/migrate/20250624230522_create_parent_employment.rb b/db/migrate/20250624230522_create_parent_employment.rb new file mode 100644 index 00000000..062854a1 --- /dev/null +++ b/db/migrate/20250624230522_create_parent_employment.rb @@ -0,0 +1,10 @@ +class CreateParentEmployment < ActiveRecord::Migration[8.0] + def change + create_table :parent_employments do |t| + t.references :parent, null: false, foreign_key: true + t.references :employment, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d690e3f8..095073e0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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_06_11_182208) do +ActiveRecord::Schema[8.0].define(version: 2025_06_24_230522) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -50,6 +50,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do t.index ["school_id"], name: "index_admin_data_values_on_school_id" end + create_table "benefits", force: :cascade do |t| + t.string "designation" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "categories", id: :serial, force: :cascade do |t| t.string "name" t.text "description" @@ -77,6 +83,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do t.index ["slug"], name: "index_districts_on_slug", unique: true end + create_table "educations", force: :cascade do |t| + t.string "designation" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "ells", force: :cascade do |t| t.string "designation" t.string "slug" @@ -85,6 +97,12 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do t.index ["designation"], name: "index_ells_on_designation", unique: true end + create_table "employments", force: :cascade do |t| + t.string "designation" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "genders", force: :cascade do |t| t.integer "qualtrics_code" t.string "designation" @@ -336,6 +354,15 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do t.index ["subcategory_id"], name: "index_measures_on_subcategory_id" end + create_table "parent_employments", force: :cascade do |t| + t.bigint "parent_id", null: false + t.bigint "employment_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["employment_id"], name: "index_parent_employments_on_employment_id" + t.index ["parent_id"], name: "index_parent_employments_on_parent_id" + end + create_table "parent_genders", force: :cascade do |t| t.bigint "parent_id", null: false t.bigint "gender_id", null: false @@ -370,6 +397,10 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.bigint "housing_id" + t.bigint "education_id" + t.bigint "benefits_id" + t.index ["benefits_id"], name: "index_parents_on_benefits_id" + t.index ["education_id"], name: "index_parents_on_education_id" t.index ["housing_id"], name: "index_parents_on_housing_id" end @@ -558,12 +589,16 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_11_182208) do add_foreign_key "legacy_school_categories", "legacy_categories", column: "category_id" add_foreign_key "legacy_school_categories", "legacy_schools", column: "school_id" add_foreign_key "measures", "subcategories" + add_foreign_key "parent_employments", "employments" + add_foreign_key "parent_employments", "parents" add_foreign_key "parent_genders", "genders" add_foreign_key "parent_genders", "parents" add_foreign_key "parent_languages", "languages" add_foreign_key "parent_languages", "parents" add_foreign_key "parent_races", "parents" add_foreign_key "parent_races", "races" + add_foreign_key "parents", "benefits", column: "benefits_id" + add_foreign_key "parents", "educations" add_foreign_key "parents", "housings" add_foreign_key "respondents", "academic_years" add_foreign_key "respondents", "schools" diff --git a/spec/factories.rb b/spec/factories.rb index 81f184bf..a5572c75 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,4 +1,16 @@ FactoryBot.define do + factory :benefit do + designation { "MyString" } + end + + factory :education do + designation { "MyString" } + end + + factory :employment do + designation { "MyString" } + end + factory :parent_language do parent { nil } language { nil } diff --git a/spec/fixtures/test_2020-21_parent_survey_responses.csv b/spec/fixtures/test_2020-21_parent_survey_responses.csv index 6b0507d9..22b51740 100644 --- a/spec/fixtures/test_2020-21_parent_survey_responses.csv +++ b/spec/fixtures/test_2020-21_parent_survey_responses.csv @@ -1,9 +1,9 @@ StartDate,EndDate,Status,IPAddress,Progress,Duration (in seconds),Finished,RecordedDate,ResponseId,DistributionChannel,UserLanguage,DESE ID,Number of Children,Gender-1,Gender-1_7_TEXT,Race-1,Race-1_7_TEXT,Gender-2,Gender-2_7_TEXT,Race-2,Race-2_7_TEXT,Gender-3,Gender-3_7_TEXT,Race-3,Race-3_7_TEXT,Gender-4,Gender-4_7_TEXT,Race-4,Race-4_7_TEXT,Gender-5,Gender-5_7_TEXT,Race-5,Race-5_7_TEXT,Gender,Gender_7_TEXT,p-scrp-q3,p-scrp-q2,p-valm-q1,p-valm-q2,p-valm-q3,p-valm-q4,p-comm-q1,p-comm-q2,p-comm-q3,p-tcom-q1,P-tcom-q2,p-tcom-q3,p-evnt-q4,p-comm-q4,p-evnt-q3,p-evnt-q1,p-evnt-q2,p-socx-q3,p-socx-q4,p-scrp-q1,p-socx-q1,p-sosu-q1,p-sosu-q2,p-sosu-q3,p-socx-q2,p-sosu-q4,p-phys-q3,p-acpr-q1,p-acpr-q2,p-acpr-q3,p-acpr-q4,p-cure-q1,p-cure-q2,p-cure-q3,p-cure-q4,Housing,Housing_100_TEXT,Employment,Employment_100_TEXT,Caregivers,Caregivers_100_TEXT,Education,Education_100_TEXT,Benefits,Benefits_100_TEXT,Language,Language_100_TEXT,Raw Income,Income,Raw ELL,ELL,Raw SpEd,SpEd,Progress Count -5/1/2024 10:04:34,5/1/2024 10:10:49,0,72.93.86.98,100,374,1,2021-03-31T10:01:36,parent_survey_response_1,email,EN,1500025,1,,,1,,,,,,,,,,,,,,,,,,2,,4,5,5,4,5,5,5,5,5,4,4,5,4,5,3,4,5,4,4,5,5,5,5,5,5,5,1,2,2,2,1,4,5,5,5,1,,1,,2,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 -5/1/2024 10:03:52,5/1/2024 10:14:42,0,73.69.182.58,100,649,1,2021-04-01T10:01:36,parent_survey_response_2,email,EN,1500025,1,,,,,,,,,,,6,,,,7,,,,,,1,,4,4,5,5,5,5,5,5,5,5,5,5,3,5,4,5,5,5,5,5,4,4,4,4,5,5,1,5,4,5,5,5,5,5,5,1,,99,,2,,3,,1,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 -5/1/2024 10:06:44,5/1/2024 10:15:41,0,50.235.109.170,100,537,1,2021-04-02T10:01:36,parent_survey_response_3,email,EN,1500025,2,1,,4,,2,,"1,5",,,,,,,,,,,,,,2,,5,5,5,4,5,5,5,5,5,4,4,5,4,4,3,4,4,4,4,5,4,4,5,5,2,5,3,4,4,4,4,5,5,5,5,1,,1,,3,,6,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 -5/1/2024 10:14:23,5/1/2024 10:22:22,0,73.38.238.192,100,478,1,2021-04-03T10:01:36,parent_survey_response_4,email,EN,1500025,1,3,,7,,,,,,,,,,,,,,,,,,4,,5,5,5,5,5,5,5,4,5,4,4,4,2,5,4,5,4,5,5,5,3,5,5,5,2,5,1,5,5,5,5,5,5,5,5,1,,1,,2,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 +5/1/2024 10:04:34,5/1/2024 10:10:49,0,72.93.86.98,100,374,1,2021-03-31T10:01:36,parent_survey_response_1,email,EN,1500025,1,,,1,,,,,,,,,,,,,,,,,,2,,4,5,5,4,5,5,5,5,5,4,4,5,4,5,3,4,5,4,4,5,5,5,5,5,5,5,1,2,2,2,1,4,5,5,5,1,,1,,2,,1,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 +5/1/2024 10:03:52,5/1/2024 10:14:42,0,73.69.182.58,100,649,1,2021-04-01T10:01:36,parent_survey_response_2,email,EN,1500025,1,,,,,,,,,,,6,,,,7,,,,,,1,,4,4,5,5,5,5,5,5,5,5,5,5,3,5,4,5,5,5,5,5,4,4,4,4,5,5,1,5,4,5,5,5,5,5,5,1,,99,,2,,2,,1,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 +5/1/2024 10:06:44,5/1/2024 10:15:41,0,50.235.109.170,100,537,1,2021-04-02T10:01:36,parent_survey_response_3,email,EN,1500025,2,1,,4,,2,,"1,5",,,,,,,,,,,,,,2,,5,5,5,4,5,5,5,5,5,4,4,5,4,4,3,4,4,4,4,5,4,4,5,5,2,5,3,4,4,4,4,5,5,5,5,1,,1,,3,,3,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 +5/1/2024 10:14:23,5/1/2024 10:22:22,0,73.38.238.192,100,478,1,2021-04-03T10:01:36,parent_survey_response_4,email,EN,1500025,1,3,,7,,,,,,,,,,,,,,,,,,4,,5,5,5,5,5,5,5,4,5,4,4,4,2,5,4,5,4,5,5,5,3,5,5,5,2,5,1,5,5,5,5,5,5,5,5,1,,1,,2,,4,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 5/1/2024 10:18:39,5/1/2024 10:23:49,0,73.69.158.255,100,310,1,2021-04-04T10:01:36,parent_survey_response_5,email,EN,1500025,2,2,,"1,2,3",,,,"4,5,8",,,,,,,,,,,,,,2,,5,4,5,5,5,5,1,1,1,1,1,1,3,1,4,4,5,1,1,1,4,1,1,1,4,5,1,5,5,5,5,1,5,1,1,1,,"2,4",,3,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 -5/1/2024 10:20:30,5/1/2024 10:25:16,0,73.182.146.201,100,285,1,2021-04-05T10:01:36,parent_survey_response_6,email,EN,1500025,1,,,,,,,,,,,,,,,1,,,,"2,3,4,5,8",,,,3,3,3,1,3,2,4,2,4,1,1,3,3,4,3,4,1,5,5,4,3,5,4,3,3,1,3,5,5,4,5,4,4,5,4,2,,2,,2,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 -5/1/2024 10:14:01,5/1/2024 10:27:19,0,209.107.182.203,100,798,1,2021-04-06T10:01:36,parent_survey_response_7,email,EN,1500025,2,6,,5,,,,5,,,,,,,,,,,,,,,,3,3,3,1,3,2,4,2,4,1,1,3,3,4,3,4,1,5,5,4,3,5,4,3,3,1,3,5,5,4,5,4,4,5,4,1,,1,,2,,5,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 +5/1/2024 10:20:30,5/1/2024 10:25:16,0,73.182.146.201,100,285,1,2021-04-05T10:01:36,parent_survey_response_6,email,EN,1500025,1,,,,,,,,,,,,,,,1,,,,"2,3,4,5,8",,,,3,3,3,1,3,2,4,2,4,1,1,3,3,4,3,4,1,5,5,4,3,5,4,3,3,1,3,5,5,4,5,4,4,5,4,2,,2,,2,,99,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 +5/1/2024 10:14:01,5/1/2024 10:27:19,0,209.107.182.203,100,798,1,2021-04-06T10:01:36,parent_survey_response_7,email,EN,1500025,2,6,,5,,,,5,,,,,,,,,,,,,,,,3,3,3,1,3,2,4,2,4,1,1,3,3,4,3,4,1,5,5,4,3,5,4,3,3,1,3,5,5,4,5,4,4,5,4,1,,1,,2,,100,,2,,1,,,Economically Disadvantaged - N,,Not ELL,,Not Special Education,34 5/1/2024 10:14:01,5/1/2024 10:27:19,0,209.107.182.203,100,798,1,2021-04-06T10:01:36,parent_survey_response_8,email,EN,1500025,2,Prefer not to disclose,,5,,,,5,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, diff --git a/spec/models/benefit_spec.rb b/spec/models/benefit_spec.rb new file mode 100644 index 00000000..16881755 --- /dev/null +++ b/spec/models/benefit_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Benefit, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/education_spec.rb b/spec/models/education_spec.rb new file mode 100644 index 00000000..5e0fd26f --- /dev/null +++ b/spec/models/education_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Education, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/employment_spec.rb b/spec/models/employment_spec.rb new file mode 100644 index 00000000..d59c532d --- /dev/null +++ b/spec/models/employment_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Employment, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/services/cleaner_spec.rb b/spec/services/cleaner_spec.rb index 7e563b39..ee0ae9a1 100644 --- a/spec/services/cleaner_spec.rb +++ b/spec/services/cleaner_spec.rb @@ -182,15 +182,12 @@ RSpec.describe Cleaner do 1027 1028] valid_rows.each do |response_id| valid_row = data.find { |row| row.response_id == response_id } - byebug unless valid_row.valid? == true - expect(valid_row.valid?).to eq true end invalid_rows = %w[1002 1006 1007 1009 1010 1011 1012 1013 1014 1015 1016 1021 1022 1023 1025 1029 1030 1031 1032 1033 1034] invalid_rows.each do |response_id| invalid_row = data.find { |row| row.response_id == response_id } - byebug if invalid_row.valid? == true expect(invalid_row.valid?).to eq false end diff --git a/spec/services/survey_responses_data_loader_spec.rb b/spec/services/survey_responses_data_loader_spec.rb index 3655c30d..656f2a2d 100644 --- a/spec/services/survey_responses_data_loader_spec.rb +++ b/spec/services/survey_responses_data_loader_spec.rb @@ -136,6 +136,48 @@ describe SurveyResponsesDataLoader do create(:language, designation: "Unknown") end + let(:education_list) do + designations = [ + "No formal schooling completed", + "Some formal schooling", + "High school diploma or GED", + "Associates Degree", + "Bachelors Degree", + "Masters Degree", + "Professional Degree", + "Doctoral Degree", + "Unknown" + ] + designations.map do |designation| + create(:education, designation:) + end + end + + let(:employment_list) do + designations = [ + "Two adults with full-time employment", + "One adult with full-time employment", + "Two adults with part-time employment", + "One adult with part-time employment", + "No full-time or part-time employment", + "Unknown" + ] + designations.map do |designation| + create(:employment, designation:) + end + end + + let(:benefit_list) do + designations = [ + "Yes", + "No", + "Unknown" + ] + designations.map do |designation| + create(:benefit, designation:) + end + end + let(:setup) do ay_2020_21 ay_2022_23 @@ -177,6 +219,9 @@ describe SurveyResponsesDataLoader do multiracial languages + education_list + employment_list + benefit_list end before :each do @@ -281,6 +326,20 @@ describe SurveyResponsesDataLoader do it "loads the correct set of genders for parents" do assigns_genders_to_parents end + + it "assigns the correct education for parents" do + results = { "parent_survey_response_1" => "No formal schooling completed", + "parent_survey_response_2" => "Some formal schooling", + "parent_survey_response_3" => "High school diploma or GED", + "parent_survey_response_4" => "Associates Degree", + "parent_survey_response_5" => "Bachelors Degree", + "parent_survey_response_6" => "Unknown", + "parent_survey_response_7" => "Unknown" } + + results.each do |key, value| + expect(SurveyItemResponse.where(response_id: key).first.parent.education.designation).to eq value + end + end end end