mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
fix: correctly memoize student_survey_items_with_sufficient_responses so that on the analyze page, when the first year has insufficient responses, it doesn't affect all subsequent years
This commit is contained in:
parent
3b3bb52523
commit
3f2aa63bfd
4 changed files with 32 additions and 20 deletions
|
|
@ -25,7 +25,8 @@ class Measure < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def student_survey_items_with_sufficient_responses(school:, academic_year:)
|
||||
@student_survey_items_with_sufficient_responses ||= SurveyItem.where(id: SurveyItem.joins("inner join survey_item_responses on survey_item_responses.survey_item_id = survey_items.id")
|
||||
@student_survey_items_with_sufficient_responses ||= Hash.new do |memo, (school, academic_year)|
|
||||
memo[[school, academic_year]] = SurveyItem.where(id: SurveyItem.joins("inner join survey_item_responses on survey_item_responses.survey_item_id = survey_items.id")
|
||||
.student_survey_items
|
||||
.where("survey_item_responses.school": school,
|
||||
"survey_item_responses.academic_year": academic_year,
|
||||
|
|
@ -34,6 +35,8 @@ class Measure < ActiveRecord::Base
|
|||
.group("survey_items.id")
|
||||
.having("count(*) >= 10")
|
||||
.count.keys)
|
||||
end
|
||||
@student_survey_items_with_sufficient_responses[[school, academic_year]]
|
||||
end
|
||||
|
||||
def teacher_scales
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue