It's possible for admin data likert score values to be above 5. If that happens, we

cap the likert score at 5.   This was happening already at the scraper
level but it's also now being done by the admin data loader for safety.
Also make sure to just update admin data instead of deleting and
reloading all values each load. Add tests to confirm this behavior
This commit is contained in:
rebuilt 2023-06-03 15:05:24 -07:00
parent 3589878700
commit 904d0d2f2c
4 changed files with 97 additions and 58 deletions

View file

@ -0,0 +1,13 @@
District,School,DESE ID,Category,Item ID,NonLikert Title,NL_Value,LikertScore,Benchmark,Data Type,Academic Year
Attleboro,Attleboro High School,160505,2-C-i,a-vale-i1,Chronic absence rate,19.7,1,10,%,2018-19
Milford,Woodland Elementary School,1850090,2-C-i,a-vale-i1,Chronic absence rate,6.8,1,10,%,2018-19
Revere,Beachmont Elementary School,2480013,2-C-i,a-vale-i1,Chronic absence rate,4.2,1,10,%,2018-19
Winchester,Winchester High School,3440505,2-C-i,a-vale-i1,Chronic absence rate,7.2,1,10,%,2018-19
Attleboro,Attleboro High School,160505,3-A-i,a-reso-i1,Average class size,20.6,2,20,,2018-19
Milford,Woodland Elementary School,1850090,3-A-i,a-reso-i1,Average class size,22.5,2,20,,2018-19
Revere,Beachmont Elementary School,2480013,3-A-i,a-reso-i1,Average class size,17,2,20,,2018-19
Winchester,Winchester High School,3440505,3-A-i,a-reso-i1,Average class size,17,2,20,,2018-19
Attleboro,Attleboro High School,160505,3-A-ii,a-sust-i3,Student to instructional support staff ratio,15.28896673,3,43.4,,2018-19
Milford,Woodland Elementary School,1850090,3-A-ii,a-sust-i3,Student to instructional support staff ratio,22.85714286,3,43.4,,2018-19
Revere,Beachmont Elementary School,2480013,3-A-ii,a-sust-i3,Student to instructional support staff ratio,38,3,43.4,,2018-19
Winchester,Winchester High School,3440505,3-A-ii,a-sust-i3,Student to instructional support staff ratio,135.9,3,43.4,,2018-19
1 District School DESE ID Category Item ID NonLikert Title NL_Value LikertScore Benchmark Data Type Academic Year
2 Attleboro Attleboro High School 160505 2-C-i a-vale-i1 Chronic absence rate 19.7 1 10 % 2018-19
3 Milford Woodland Elementary School 1850090 2-C-i a-vale-i1 Chronic absence rate 6.8 1 10 % 2018-19
4 Revere Beachmont Elementary School 2480013 2-C-i a-vale-i1 Chronic absence rate 4.2 1 10 % 2018-19
5 Winchester Winchester High School 3440505 2-C-i a-vale-i1 Chronic absence rate 7.2 1 10 % 2018-19
6 Attleboro Attleboro High School 160505 3-A-i a-reso-i1 Average class size 20.6 2 20 2018-19
7 Milford Woodland Elementary School 1850090 3-A-i a-reso-i1 Average class size 22.5 2 20 2018-19
8 Revere Beachmont Elementary School 2480013 3-A-i a-reso-i1 Average class size 17 2 20 2018-19
9 Winchester Winchester High School 3440505 3-A-i a-reso-i1 Average class size 17 2 20 2018-19
10 Attleboro Attleboro High School 160505 3-A-ii a-sust-i3 Student to instructional support staff ratio 15.28896673 3 43.4 2018-19
11 Milford Woodland Elementary School 1850090 3-A-ii a-sust-i3 Student to instructional support staff ratio 22.85714286 3 43.4 2018-19
12 Revere Beachmont Elementary School 2480013 3-A-ii a-sust-i3 Student to instructional support staff ratio 38 3 43.4 2018-19
13 Winchester Winchester High School 3440505 3-A-ii a-sust-i3 Student to instructional support staff ratio 135.9 3 43.4 2018-19

View file

@ -2,6 +2,7 @@ require 'rails_helper'
describe AdminDataLoader do
let(:path_to_admin_data) { Rails.root.join('spec', 'fixtures', 'sample_admin_data.csv') }
let(:path_to_secondary_admin_data) { Rails.root.join('spec', 'fixtures', 'secondary_sample_admin_data.csv') }
let(:ay_2018_19) { AcademicYear.find_by_range '2018-19' }
let(:attleboro) { School.find_by_dese_id 160_505 }
let(:winchester) { School.find_by_dese_id 3_440_505 }
@ -29,7 +30,7 @@ describe AdminDataLoader do
# it 'assigns the school to the admin data value' do
expect(AdminDataValue.first.school).to eq attleboro
expect(AdminDataValue.last.school).to eq beachmont
expect(AdminDataValue.last.school).to eq winchester
# end
# it 'links the admin data value to the correct admin data item' do
@ -38,7 +39,7 @@ describe AdminDataLoader do
# end
# it 'loads all the admin data values in the target csv file' do
expect(AdminDataValue.count).to eq 10
expect(AdminDataValue.count).to eq 11
# end
# it 'captures the likert score ' do
@ -46,6 +47,8 @@ describe AdminDataLoader do
admin_data_item: chronic_absense_rate).likert_score).to eq 3.03
expect(AdminDataValue.find_by(school: beachmont, academic_year: ay_2018_19,
admin_data_item: student_to_instructor_ratio).likert_score).to eq 3.5
expect(AdminDataValue.find_by(school: winchester, academic_year: ay_2018_19,
admin_data_item: student_to_instructor_ratio).likert_score).to eq 5
# end
# it 'rounds up any likert_scores between 0 and 1 (non-inclusive) to 1' do
@ -55,16 +58,27 @@ describe AdminDataLoader do
# it 'rejects importing rows with a value of 0' do
expect(AdminDataValue.where(school: attleboro, academic_year: ay_2018_19,
admin_data_item: AdminDataItem.find_by_admin_data_item_id('a-reso-i1'))).not_to exist
expect(AdminDataValue.where(school: winchester, academic_year: ay_2018_19,
admin_data_item: AdminDataItem.find_by_admin_data_item_id('a-sust-i3'))).not_to exist
# end
end
context 'when a second file exists' do
before :each do
AdminDataLoader.load_data filepath: path_to_secondary_admin_data
end
it 'updates likert scores to match the new file' do
expect(AdminDataValue.find_by(school: attleboro, academic_year: ay_2018_19,
admin_data_item: chronic_absense_rate).likert_score).to eq 1
expect(AdminDataValue.find_by(school: beachmont, academic_year: ay_2018_19,
admin_data_item: student_to_instructor_ratio).likert_score).to eq 3
end
end
end
describe 'output to console' do
it 'outputs a messsage saying a value has been rejected' do
output = capture_stdout { AdminDataLoader.load_data filepath: path_to_admin_data }.gsub("\n", '')
expect(output).to eq 'Invalid score: 0.0 for school: Attleboro High School admin data item a-reso-i1 Invalid score: 100.0 for school: Winchester High School admin data item a-sust-i3 '
output = capture_stdout { AdminDataLoader.load_data filepath: path_to_admin_data }.delete("\n")
expect(output).to eq 'Invalid score: 0.0 for school: Attleboro High School admin data item a-reso-i1 '
end
end
end