mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
perf: reduce number of calls for student and teacher survey items in response rate calculators
This commit is contained in:
parent
ec5c1bd1ef
commit
edbb84334a
3 changed files with 10 additions and 2 deletions
|
|
@ -49,7 +49,7 @@ class StudentResponseRateCalculator < ResponseRateCalculator
|
|||
value < threshold
|
||||
end
|
||||
|
||||
ssi = @subcategory.survey_items.student_survey_items.map(&:id)
|
||||
ssi = @subcategory.student_survey_items.map(&:id)
|
||||
grade_array = Array.new(ssi.length, grade)
|
||||
|
||||
memo[grade] = si.slice(*grade_array.zip(ssi))
|
||||
|
|
|
|||
|
|
@ -91,4 +91,12 @@ class Subcategory < ActiveRecord::Base
|
|||
Zones.new(watch_low_benchmark:, growth_low_benchmark:,
|
||||
approval_low_benchmark:, ideal_low_benchmark:).zone_for_score(score)
|
||||
end
|
||||
|
||||
def student_survey_items
|
||||
@student_survey_items ||= survey_items.student_survey_items
|
||||
end
|
||||
|
||||
def teacher_survey_items
|
||||
@teacher_survey_items ||= survey_items.teacher_survey_items
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class TeacherResponseRateCalculator < ResponseRateCalculator
|
|||
def survey_items_with_sufficient_responses
|
||||
@survey_items_with_sufficient_responses ||= SurveyItemResponse.teacher_survey_items_with_sufficient_responses(
|
||||
school:, academic_year:
|
||||
).slice(*@subcategory.survey_items.teacher_survey_items.map(&:id))
|
||||
).slice(*@subcategory.teacher_survey_items.map(&:id))
|
||||
end
|
||||
|
||||
def response_count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue