mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
feat: Add language filter for parent analysis
This commit is contained in:
parent
3eda7beb59
commit
8e5e2a030a
8 changed files with 35 additions and 3 deletions
|
|
@ -79,7 +79,7 @@ class Cleaner
|
||||||
|
|
||||||
headers = headers.to_set
|
headers = headers.to_set
|
||||||
headers = headers.merge(Set.new(["Raw Income", "Income", "Raw ELL", "ELL", "Raw SpEd", "SpEd", "Progress Count",
|
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", "Home Language"])).to_a
|
||||||
filtered_headers = include_all_headers(headers:)
|
filtered_headers = include_all_headers(headers:)
|
||||||
filtered_headers = remove_unwanted_headers(headers: filtered_headers)
|
filtered_headers = remove_unwanted_headers(headers: filtered_headers)
|
||||||
log_headers = (filtered_headers + ["Valid Duration?", "Valid Progress?", "Valid Grade?",
|
log_headers = (filtered_headers + ["Valid Duration?", "Valid Progress?", "Valid Grade?",
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ class DemographicLoader
|
||||||
create_from_column(column: "Income", row:, model: Income)
|
create_from_column(column: "Income", row:, model: Income)
|
||||||
create_from_column(column: "ELL", row:, model: Ell)
|
create_from_column(column: "ELL", row:, model: Ell)
|
||||||
create_from_column(column: "Special Ed Status", row:, model: Sped)
|
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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ class SurveyItemValues
|
||||||
# Only check the secondary hispanic column if we don't have self reported data and are relying on SIS data
|
# Only check the secondary hispanic column if we don't have self reported data and are relying on SIS data
|
||||||
if self_report.nil? && sis.present?
|
if self_report.nil? && sis.present?
|
||||||
hispanic = value_from(pattern: /Hispanic\s*Latino/i)&.downcase
|
hispanic = value_from(pattern: /Hispanic\s*Latino/i)&.downcase
|
||||||
race_codes = race_codes.reject { |code| code == 5 } if hispanic == "true" && race_codes.count == 1
|
race_codes = race_codes.reject { |code| code == 5 } if ["true", "1"].include?(hispanic) || race_codes.count == 1
|
||||||
race_codes = race_codes.push(4) if %w[true 1].include?(hispanic)
|
race_codes = race_codes.push(4) if %w[true 1].include?(hispanic)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,8 @@ class SurveyResponsesDataLoader
|
||||||
end
|
end
|
||||||
|
|
||||||
if row.respondent_type == :parent
|
if row.respondent_type == :parent
|
||||||
parent = Parent.find_or_create_by(response_id: row.response_id)
|
unknown_housing = Housing.find_by(designation: row.housing).id
|
||||||
|
parent = Parent.find_or_create_by(response_id: row.response_id, housing_id: unknown_housing)
|
||||||
parent.number_of_children = row.number_of_children
|
parent.number_of_children = row.number_of_children
|
||||||
tmp_languages = row.languages.map { |language| languages[language] }
|
tmp_languages = row.languages.map { |language| languages[language] }
|
||||||
parent.languages.concat(tmp_languages)
|
parent.languages.concat(tmp_languages)
|
||||||
|
|
|
||||||
7
db/migrate/20250408212201_add_housing_to_parent.rb
Normal file
7
db/migrate/20250408212201_add_housing_to_parent.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
class AddHousingToParent < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
add_reference :parents, :housing, foreign_key: true
|
||||||
|
Parent.update_all(housing_id: Housing.find_by(designation: 'Unknown').id)
|
||||||
|
change_column_null :parents, :housing_id, false
|
||||||
|
end
|
||||||
|
end
|
||||||
10
db/migrate/20250411213850_create_languages.rb
Normal file
10
db/migrate/20250411213850_create_languages.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
class CreateLanguages < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
create_table :languages do |t|
|
||||||
|
t.string :designation
|
||||||
|
t.string :slug
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
5
spec/models/language_spec.rb
Normal file
5
spec/models/language_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Language, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
|
|
@ -91,6 +91,12 @@ describe SurveyResponsesDataLoader do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:housings) do
|
||||||
|
create(:housing, designation: "Own")
|
||||||
|
create(:housing, designation: "Rent")
|
||||||
|
create(:housing, designation: "Unknown")
|
||||||
|
end
|
||||||
|
|
||||||
let(:t_pcom_q3) { create(:survey_item, survey_item_id: "t-pcom-q3") }
|
let(:t_pcom_q3) { create(:survey_item, survey_item_id: "t-pcom-q3") }
|
||||||
let(:t_pcom_q2) { create(:survey_item, survey_item_id: "t-pcom-q2") }
|
let(:t_pcom_q2) { create(:survey_item, survey_item_id: "t-pcom-q2") }
|
||||||
let(:t_coll_q1) { create(:survey_item, survey_item_id: "t-coll-q1") }
|
let(:t_coll_q1) { create(:survey_item, survey_item_id: "t-coll-q1") }
|
||||||
|
|
@ -136,6 +142,7 @@ describe SurveyResponsesDataLoader do
|
||||||
school
|
school
|
||||||
second_school
|
second_school
|
||||||
butler_school
|
butler_school
|
||||||
|
housings
|
||||||
t_pcom_q3
|
t_pcom_q3
|
||||||
t_pcom_q2
|
t_pcom_q2
|
||||||
t_coll_q1
|
t_coll_q1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue