feat: add parent survey gauges

This commit is contained in:
Nelson Jovel 2024-09-05 16:20:25 -07:00
parent 973f59c299
commit e5e969b968
14 changed files with 307 additions and 11 deletions

File diff suppressed because one or more lines are too long

View file

@ -36,6 +36,10 @@ RSpec.describe Cleaner do
File.open(Rails.root.join("spec", "fixtures", "raw", "sample_file_with_duplicate_headers.csv"))
end
let(:path_to_sample_raw_parent_file) do
File.open(Rails.root.join("spec", "fixtures", "raw", "sample_maynard_raw_parent_survey.csv"))
end
let(:common_headers) do
["Recorded Date", "Dese ID", "ResponseID"]
end
@ -82,6 +86,51 @@ RSpec.describe Cleaner do
survey_item_ids
end
let(:parent_survey_items) do
survey_item_ids = (%w[
p-socx-q1
p-socx-q2
p-socx-q3
p-socx-q4
p-sosu-q1
p-sosu-q2
p-sosu-q3
p-sosu-q4
p-tcom-q1
p-tcom-q2
p-tcom-q3
p-comm-q1
p-comm-q2
p-comm-q3
p-comm-q4
p-valm-q1
p-valm-q2
p-valm-q3
p-valm-q4
p-acpr-q1
p-acpr-q2
p-acpr-q3
p-acpr-q4
p-scrp-q3
p-cure-q1
p-cure-q2
p-cure-q3
p-cure-q4
p-evnt-q1
p-evnt-q2
p-evnt-q3
p-evnt-q4
p-phys-q3
p-scrp-q1
p-scrp-q2
] << common_headers).flatten
survey_item_ids.map do |survey_item_id|
create(:survey_item, survey_item_id:)
end
survey_item_ids
end
before :each do
school
second_school
@ -198,6 +247,19 @@ RSpec.describe Cleaner do
end
end
context "when the file is based on parent survey items" do
it "adds the survey type as parent to the filename" do
survey_items = SurveyItem.where(survey_item_id: parent_survey_items)
data = [SurveyItemValues.new(row: { "Recorded Date" => recorded_date, "Dese ID" => "1_740_505" }, headers: parent_survey_items, survey_items:,
schools: School.by_dese_id)]
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
headers: parent_survey_items, data:, filepath: nil
)
expect(filename).to eq "maynard.maynard-high-school.parent.2022-23.csv"
end
end
context "when there is more than one district" do
it "adds all districts to the filename" do
survey_items = SurveyItem.where(survey_item_id: teacher_survey_items)