mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Rename ResponseRate to ResponseRateCalculator. Create a new response
rate model. Create a loader to refresh response rates for all subcategories. Use precalculated response rates in views Wrap more elements in page caching Calculate a response rate for a subcategory if one does not already exist
This commit is contained in:
parent
dfc5202b88
commit
c03615cb43
16 changed files with 352 additions and 177 deletions
34
app/services/response_rate_loader.rb
Normal file
34
app/services/response_rate_loader.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class ResponseRateLoader
|
||||
def self.refresh
|
||||
schools = School.all
|
||||
academic_years = AcademicYear.all
|
||||
subcategories = Subcategory.all
|
||||
|
||||
milford = School.find_by_slug 'milford-high-school'
|
||||
|
||||
# ResponseRate.new(school:, academic_year:, subcategory:, student_response_rate: 50, teacher_response_rate: 50,
|
||||
# meets_student_threshold: true, meets_teacher_threshold: true).save
|
||||
|
||||
test_year = AcademicYear.find_by_range '2020-21'
|
||||
subcategories.each do |subcategory|
|
||||
schools.each do |school|
|
||||
next if ENV['RAILS_ENV'] == 'test' && !(school == milford)
|
||||
|
||||
academic_years.each do |academic_year|
|
||||
next if ENV['RAILS_ENV'] == 'test' && !(academic_year == test_year)
|
||||
|
||||
student = StudentResponseRateCalculator.new(subcategory:, school:, academic_year:)
|
||||
teacher = TeacherResponseRateCalculator.new(subcategory:, school:, academic_year:)
|
||||
|
||||
response_rate = ResponseRate.find_or_create_by!(subcategory:, school:, academic_year:)
|
||||
|
||||
response_rate.student_response_rate = student.rate
|
||||
response_rate.teacher_response_rate = teacher.rate
|
||||
response_rate.meets_student_threshold = student.meets_student_threshold?
|
||||
response_rate.meets_teacher_threshold = teacher.meets_teacher_threshold?
|
||||
response_rate.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue