chore: memoize grades for school

speedup-admin-data
Nelson Jovel 2 years ago
parent 60927e3271
commit cc5e0b142c

@ -21,6 +21,6 @@ class School < ApplicationRecord
end
def grades(academic_year:)
Respondent.find_by(school: self, academic_year:)&.enrollment_by_grade&.keys || (-1..12).to_a
@grades ||= Respondent.find_by(school: self, academic_year:)&.enrollment_by_grade&.keys || (-1..12).to_a
end
end

Loading…
Cancel
Save