chore: memoize grades for school

This commit is contained in:
Nelson Jovel 2023-12-21 13:44:07 -08:00
parent 60927e3271
commit cc5e0b142c

View file

@ -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