From 5dc79e5da7e984d9b4a39bbf889178b4923e040c Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Fri, 21 Dec 2018 13:50:24 -0500 Subject: [PATCH] fixing bugs with school_question creation --- db/schema.rb | 3 ++- lib/tasks/data.rake | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index d142f07e..952a98a1 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: 20181218154720) do +ActiveRecord::Schema.define(version: 20181221180917) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -168,6 +168,7 @@ ActiveRecord::Schema.define(version: 20181218154720) do t.string "year" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "response_total" end create_table "schools", force: :cascade do |t| diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index d3894691..ca0d26f5 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -461,6 +461,7 @@ namespace :data do next if school.district.name != "Boston" attempt_data = Attempt. + joins(:question). created_in(school_category.year). for_question(question). for_school(school). @@ -469,7 +470,7 @@ namespace :data do available_responders = school.available_responders_for(question) - school_question = school_category.school_questions.for(school, question) + school_question = school_category.school_questions.for(school, question).first if school_question.present? school_questions << school_question else