mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
fix: I broke the feature where the site would automatically navigate the user to the latest year that had sufficient data when I made response rates calculate on each page load instead of being precalculated and stored in the database. Instead of a database lookup for response rates that meet the sufficiency threshold, I caculate the latest year when a user chooses a school from the welcome page.
This commit is contained in:
parent
f230f76bc6
commit
77e2b1e203
1 changed files with 9 additions and 6 deletions
|
|
@ -43,12 +43,15 @@ class HomeController < ApplicationController
|
|||
end
|
||||
|
||||
def year
|
||||
latest_response_rate = ResponseRate.where(school:)
|
||||
.where('meets_student_threshold = ? or meets_teacher_threshold = ?', true, true)
|
||||
.joins('inner join academic_years a on response_rates.academic_year_id=a.id')
|
||||
.order('a.range DESC').first
|
||||
academic_year = latest_response_rate.academic_year.range if latest_response_rate.present?
|
||||
return nil unless school.present?
|
||||
|
||||
academic_year || AcademicYear.order('range DESC').first.range
|
||||
academic_year = AcademicYear.all.order(range: :DESC).find do |ay|
|
||||
Subcategory.all.any? do |subcategory|
|
||||
rate = subcategory.response_rate(school:, academic_year: ay)
|
||||
rate.meets_student_threshold || rate.meets_teacher_threshold
|
||||
end
|
||||
end
|
||||
|
||||
academic_year.range || AcademicYear.order("range DESC").first.range
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue