diff --git a/data/qualtrics_district_and_school_code_key.csv b/data/qualtrics_district_and_school_code_key.csv new file mode 100644 index 00000000..3eac4c83 --- /dev/null +++ b/data/qualtrics_district_and_school_code_key.csv @@ -0,0 +1,194 @@ +District,District Code,School Name,School Code, +Attleboro,1,Attleboro High School,1, +Attleboro,1,Cyril K. Brennan Middle School,2, +Attleboro,1,Robert J. Coelho Middle School,3, +Attleboro,1,Wamsutta Middle School,4, +Attleboro,1,Hill-Roberts Elementary School,5, +Attleboro,1,Hyman Fine Elementary School,6, +Attleboro,1,A. Irvin Studley Elementary School,7, +Attleboro,1,Peter Thacher Elementary School,8, +Attleboro,1,Thomas Willett Elementary School,9, +Boston,2,Samuel Adams Elementary School,1, +Boston,2,Dante Alghieri Montessori School,2, +Boston,2,Another Course to College,3, +Boston,2,Phineas Bates Elementary School,4, +Boston,2,Ludwig van Beethoven Elementary School,5, +Boston,2,Blackstone Innovation School,6, +Boston,2,Boston Arts Academy,7, +Boston,2,Boston Community Leadership Academy,8, +Boston,2,Boston Day and Evening Academy,9, +Boston,2,Boston Green Academy,10, +Boston,2,Boston International Newcomers Academy,11, +Boston,2,Boston Latin Academy,12, +Boston,2,Boston Latin School,13, +Boston,2,Boston Teachers Union K-8 School,14, +Boston,2,Manassah E. Bradley Elementary School,15, +Boston,2,Brighton High School,16, +Boston,2,Jeremiah E. Burke High School,17, +Boston,2,William E. Channing Elementary School,18, +Boston,2,Charlestown High School,19, +Boston,2,James J. Chittick Elementary School,20, +Boston,2,Clap Elementary School,21, +Boston,2,Community Academy,22, +Boston,2,Community Academy of Science and Health,23, +Boston,2,James F. Condon K-8 School,24, +Boston,2,George H. Conley Elementary School,25, +Boston,2,Curley K-8 School,26, +Boston,2,Henry Dearborn STEM Academy,27, +Boston,2,Paul A. Dever Elementary School,28, +Boston,2,Boston Collaborative High School,29, +Boston,2,Dudley Street Neighborhood Charter School,30, +Boston,2,East Boston High School,31, +Boston,2,Thomas Edison K-8 School,32, +Boston,2,Clarence R. Edwards Middle School,33, +Boston,2,John Eliot K-8 School,34, +Boston,2,David A. Ellis Elementary School,35, +Boston,2,English High School,36, +Boston,2,Edward Everett Elementary School,37, +Boston,2,Excel High School,38, +Boston,2,Fenway High School,39, +Boston,2,Lilla G. Frederick Middle School,40, +Boston,2,Gardner Pilot Academy,41, +Boston,2,Greater Egleston High School,42, +Boston,2,Sarah Greenwood K-8 School,43, +Boston,2,Henry Grew Elementary School,44, +Boston,2,Curtis Guild Elementary School,45, +Boston,2,Nathan Hale Elementary School,46, +Boston,2,Dennis Haley K-8 School,47, +Boston,2,Harvard/Kent Elementary School,48, +Boston,2,Dr. William W. Henderson K-12 Inclusion School,49, +Boston,2,James W. Hennigan K-8 School,50, +Boston,2,Rafael Hernandez K-8 School,51, +Boston,2,Higginson-Lewis School,52, +Boston,2,Oliver Wendell Holmes Elementary School,53, +Boston,2,Horace Mann School for the Deaf and Hard of Hearing,54, +Boston,2,Joseph Hurley K-8 School,55, +Boston,2,Washington Irving Middle School,56, +Boston,2,Jackson/Mann K-8 School,57, +Boston,2,Edward M. Kennedy Academy for Health Careers,58, +Boston,2,John F. Kennedy Elementary School,59, +Boston,2,Patrick Kennedy Elementary School,60, +Boston,2,Thomas J. Kenny Elementary School,61, +Boston,2,Joyce Kilmer K-8 School,62, +Boston,2,"Martin Luther King, Jr. K-8 School",63, +Boston,2,Joseph Lee K-8 School,64, +Boston,2,Patrick Lydon K-8 School,65, +Boston,2,Mary Lyon K-8 School,66, +Boston,2,Mary Lyon High School,67, +Boston,2,Madison Park Technical Vocational High School,68, +Boston,2,Joseph P. Manning Elementary School,69, +Boston,2,Samuel Mason Elementary School,70, +Boston,2,Mather Elementary School,71, +Boston,2,John W. McCormack Middle School,72, +Boston,2,Donald McKay K-8 School,73, +Boston,2,William McKinley Elementary School,74, +Boston,2,William McKinley Middle School,75, +Boston,2,William McKinley South End Academy,76, +Boston,2,William McKinley Preparatory High School,77, +Boston,2,William McKinley School,78, +Boston,2,Ellis Mendell School,79, +Boston,2,Mildred Avenue K-8 School,80, +Boston,2,Mission Hill K-8 School,81, +Boston,2,Wolfgang A. Mozart Elementary School,82, +Boston,2,Margarita Muniz Academy,83, +Boston,2,Richard J. Murphy K-8 School,84, +Boston,2,New Mission High School,85, +Boston,2,John D. O'Bryant School of Mathematics and Science,86, +Boston,2,Hugh R. O'Donnell Elementary School,87, +Boston,2,William Ohrenberger School,88, +Boston,2,Orchard Gardens K-8 School,89, +Boston,2,James Otis Elementary School,90, +Boston,2,Michael J. Perkins Elementary School,91, +Boston,2,Oliver Hazard Perry K-8 School,92, +Boston,2,John D. Philbrick Elementary School,93, +Boston,2,Josiah Quincy Elementary School,94, +Boston,2,Josiah Quincy Upper School,95, +Boston,2,Franklin D. Roosevelt K-8 School,96, +Boston,2,William E. Russell Elementary School,97, +Boston,2,Pauline A. Shaw Elementary School,98, +Boston,2,Snowden International School at Copley,99, +Boston,2,Charles Sumner Elementary School,100, +Boston,2,Charles H. Taylor Elementary School,101, +Boston,2,TechBoston Academy,102, +Boston,2,James P. Timilty Middle School,103, +Boston,2,Maurice Tobin K-8 School,104, +Boston,2,William Monroe Trotter K-8 School,105, +Boston,2,Joseph P. Tynan Elementary School,106, +Boston,2,Mario Umana Academy,107, +Boston,2,UP Academy Boston,108, +Boston,2,UP Academy Dorchester,109, +Boston,2,UP Academy Holland,110, +Boston,2,Urban Science Academy,111, +Boston,2,Warren/Prescott K-8 School,112, +Boston,2,West Roxbury Academy,113, +Boston,2,F. Lyman Winship Elementary School,114, +Boston,2,John Winthrop Elementary School,115, +Boston,2,Young Achievers Science and Math K-8 School,116, +Lowell,3,Bailey Elementary School,1, +Lowell,3,Butler Middle School,2, +Lowell,3,Cardinal O'Connell Alternative School,3, +Lowell,3,Daley Middle School,4, +Lowell,3,Greenhalge Elementary School,5, +Lowell,3,Laura Lee Therapeutic Day School,6, +Lowell,3,LeBlanc Therapeutic Day School,7, +Lowell,3,Lowell High School,8, +Lowell,3,McAuliffe Elementary School,9, +Lowell,3,McAvinnue Elementary School,10, +Lowell,3,Moody Elementary School,11, +Lowell,3,Morey Elementary School,12, +Lowell,3,Murkland Elementary School,13, +Lowell,3,Pawtucketville Memorial Elementary School,14, +Lowell,3,Pyne Arts School,15, +Lowell,3,Reilly Elementary School,16, +Lowell,3,Riverside School,17, +Lowell,3,Robinson Middle School,18, +Lowell,3,Shaughnessy Elementary School,19, +Lowell,3,STEM Academy at the Rogers School,20, +Lowell,3,Stoklosa Middle School,21, +Lowell,3,Sullivan Middle School,22, +Lowell,3,The Career Academy,23, +Lowell,3,Wang Middle School,24, +Lowell,3,Washington Elementary School,25, +Lowell,3,Bartlett Community Partnership School,26, +Lowell,3,Adie Day School,51, +Lowell,3,Abraham Lincoln Elementary School,52, +Revere,4,Beachmont Elementary School,1, +Revere,4,Garfield Elementary School,2, +Revere,4,Garfield Middle School,3, +Revere,4,Hill Elementary School,4, +Revere,4,Lincoln Elementary School,5, +Revere,4,Paul Revere Elementary School,6, +Revere,4,Whelan Elementary School,7, +Revere,4,Susan B. Anthony Middle School,8, +Revere,4,Rumney Marsh Academy,9, +Revere,4,Revere High School,10, +Revere,4,Seacoast High School,11, +Somerville,5,Arthur D. Healey School,1, +Somerville,5,Benjamin G. Brown School,2, +Somerville,5,Dr. Albert F. Argenziano School at Lincoln Park,3, +Somerville,5,East Somerville Community School,4, +Somerville,5,Full Circle High School,5, +Somerville,5,John F. Kennedy Elementary School,6, +Somerville,5,Next Wave Junior High School,5,"Next Wave and Full Circle should be combined, with both coded as 5" +Somerville,5,Somerville High School,8, +Somerville,5,West Somerville Neighborhood School,9, +Somerville,5,Winter Hill Community Innovation School,10, +Somerville,5,Michael E Capuano Early Childhood Center,12, +Winchester,6,Ambrose Elementary School,1, +Winchester,6,Lincoln Elementary School,2, +Winchester,6,Lynch Elementary School,3, +Winchester,6,Muraco Elementary School,4, +Winchester,6,Vinson-Owen Elementary School,5, +Winchester,6,McCall Middle School,6, +Winchester,6,Winchester High School,7, +Milford,7,Woodland Elementary School,1, +Milford,7,Milford High School,2, +Milford,7,Stacy Middle School,26, +Milford,7,Brookside Elementary School,3, +Milford,7,Memorial Elementary School,4, +Milford,7,Shining Star Early Childhood Center,5, +Wareham,8,Minot Forest Elementary School,2, +Wareham,8,Wareham Middle School,3, +Wareham,8,Wareham High School,4, +Wareham,8,Wareham Cooperative Alternative School,8, +Wareham,8,John William Decas Elementary School,1, \ No newline at end of file diff --git a/db/migrate/20210920193527_add_qualtrics_code_to_districts.rb b/db/migrate/20210920193527_add_qualtrics_code_to_districts.rb new file mode 100644 index 00000000..3c0df970 --- /dev/null +++ b/db/migrate/20210920193527_add_qualtrics_code_to_districts.rb @@ -0,0 +1,5 @@ +class AddQualtricsCodeToDistricts < ActiveRecord::Migration[5.0] + def change + add_column :districts, :qualtrics_code, :integer + end +end diff --git a/db/migrate/20210920194221_add_qualtrics_code_to_schools.rb b/db/migrate/20210920194221_add_qualtrics_code_to_schools.rb new file mode 100644 index 00000000..e922e9d9 --- /dev/null +++ b/db/migrate/20210920194221_add_qualtrics_code_to_schools.rb @@ -0,0 +1,5 @@ +class AddQualtricsCodeToSchools < ActiveRecord::Migration[5.0] + def change + add_column :schools, :qualtrics_code, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 38f1d546..7251f811 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.define(version: 20210920175116) do +ActiveRecord::Schema.define(version: 20210920194221) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -51,9 +51,10 @@ ActiveRecord::Schema.define(version: 20210920175116) do create_table "districts", force: :cascade do |t| t.string "name" t.integer "state_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "slug" + t.integer "qualtrics_code" t.index ["slug"], name: "index_districts_on_slug", unique: true, using: :btree end @@ -185,12 +186,13 @@ ActiveRecord::Schema.define(version: 20210920175116) do create_table "schools", force: :cascade do |t| t.string "name" t.integer "district_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.text "description" t.string "slug" t.integer "student_count" t.integer "teacher_count" + t.integer "qualtrics_code" t.index ["slug"], name: "index_schools_on_slug", unique: true, using: :btree end diff --git a/db/seeds.rb b/db/seeds.rb index 73754c09..57b1b122 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,30 @@ require 'csv' -csv_file = File.read(Rails.root.join('data', '2021-measure-key.csv')) -CSV.parse(csv_file, headers: true).each do |row| +qualtrics_district_and_school_code_key = File.read(Rails.root.join('data', 'qualtrics_district_and_school_code_key.csv')) +CSV.parse(qualtrics_district_and_school_code_key, headers: true).each do |row| + district_name = row['District'] + district_code = row['District Code'] + school_name = row['School Name'] + school_code = row['School Code'] + school_slug = school_name.parameterize + + district = District.find_by_name(district_name) + if district.nil? + District.create name: district_name, qualtrics_code: district_code, slug: district_name.parameterize, state_id: 1 + else + district.update(qualtrics_code: district_code) if district.qualtrics_code.nil? + end + + school = School.find_by_slug(school_slug) + if school.nil? + School.create district: district, name: school_name, qualtrics_code: school_code, slug: school_slug + else + school.update(qualtrics_code: school_code) if school.qualtrics_code.nil? + end +end + +measure_key_2021 = File.read(Rails.root.join('data', '2021-measure-key.csv')) +CSV.parse(measure_key_2021, headers: true).each do |row| next if row['Source'] == 'Admin Data' category_name = row['Category'] diff --git a/spec/controllers/districts_controller_spec.rb b/spec/controllers/districts_controller_spec.rb index f3634ce1..4926bd62 100644 --- a/spec/controllers/districts_controller_spec.rb +++ b/spec/controllers/districts_controller_spec.rb @@ -20,9 +20,8 @@ RSpec.describe DistrictsController, type: :controller do describe "GET #index" do it "assigns all districts as @districts" do - district = District.create! valid_attributes get :index, params: {}, session: valid_session - expect(assigns(:districts)).to eq([district]) + expect(assigns(:districts)).to eq(District.all.alphabetic) end end diff --git a/spec/features/school_dashboard_feature_spec.rb b/spec/features/school_dashboard_feature_spec.rb index 28e7ab9f..200547c6 100644 --- a/spec/features/school_dashboard_feature_spec.rb +++ b/spec/features/school_dashboard_feature_spec.rb @@ -1,8 +1,8 @@ require "rails_helper" feature "School dashboard", type: feature do - let(:district) { District.create name: 'Winchester' } - let(:school) { School.create name: 'Winchester High School', slug: 'winchester-high-school', district: district } + let(:district) { District.find_by_slug 'winchester' } + let(:school) { School.find_by_slug 'winchester-high-school' } let(:measure) { Measure.find_by_measure_id('1A-i') }