Don't add another response rate record to the database. Just calculate on the fly. Otherwise we can run into a situation where we create two response rates for a given school/academic_year/subcategory

mciea-main
rebuilt 3 years ago
parent 283845edd3
commit 049ae4548f

@ -26,8 +26,8 @@ class Subcategory < ActiveRecord::Base
def create_response_rate(school:, academic_year:)
student = StudentResponseRateCalculator.new(subcategory: self, school:, academic_year:)
teacher = TeacherResponseRateCalculator.new(subcategory: self, school:, academic_year:)
ResponseRate.create(school:, academic_year:, subcategory: self, student_response_rate: student.rate,
teacher_response_rate: teacher.rate, meets_student_threshold: student.meets_student_threshold?,
meets_teacher_threshold: teacher.meets_teacher_threshold?)
ResponseRate.new(school:, academic_year:, subcategory: self, student_response_rate: student.rate,
teacher_response_rate: teacher.rate, meets_student_threshold: student.meets_student_threshold?,
meets_teacher_threshold: teacher.meets_teacher_threshold?)
end
end

Loading…
Cancel
Save