rename SurveyItemResponse method for clarity

mciea-main
Gabe Farrell 2 years ago
parent ef7b5435ba
commit a44956bd09

@ -8,7 +8,7 @@ module Report
# Convert they keys in this hash to a hash where the key is the grade # Convert they keys in this hash to a hash where the key is the grade
# and the value is a set of sufficient survey IDs # and the value is a set of sufficient survey IDs
survey_ids_to_grades = Hash.new survey_ids_to_grades = Hash.new
SurveyItemResponse.student_survey_items_with_sufficient_responses_by_grade( SurveyItemResponse.student_survey_items_with_responses_by_grade(
school:, school:,
academic_year: academic_year:
).each do |key, count| ).each do |key, count|

@ -43,7 +43,7 @@ class StudentResponseRateCalculator < ResponseRateCalculator
quarter_of_grade = enrollment_by_grade[grade] / 4 quarter_of_grade = enrollment_by_grade[grade] / 4
threshold = threshold > quarter_of_grade ? quarter_of_grade : threshold threshold = threshold > quarter_of_grade ? quarter_of_grade : threshold
si = SurveyItemResponse.student_survey_items_with_sufficient_responses_by_grade(school:, si = SurveyItemResponse.student_survey_items_with_responses_by_grade(school:,
academic_year:) academic_year:)
si = si.reject do |_key, value| si = si.reject do |_key, value|
value < threshold value < threshold

@ -70,8 +70,8 @@ class SurveyItemResponse < ActiveRecord::Base
@teacher_survey_items_with_sufficient_responses[[school, academic_year]] @teacher_survey_items_with_sufficient_responses[[school, academic_year]]
end end
def self.student_survey_items_with_sufficient_responses_by_grade(school:, academic_year:) def self.student_survey_items_with_responses_by_grade(school:, academic_year:)
@student_survey_items_with_sufficient_responses_by_grade ||= Hash.new do |memo, (school, academic_year)| @student_survey_items_with_responses_by_grade ||= Hash.new do |memo, (school, academic_year)|
hash = SurveyItem.joins("inner join survey_item_responses on survey_item_responses.survey_item_id = survey_items.id") hash = SurveyItem.joins("inner join survey_item_responses on survey_item_responses.survey_item_id = survey_items.id")
.student_survey_items .student_survey_items
.where("survey_item_responses.school": school, "survey_item_responses.academic_year": academic_year) .where("survey_item_responses.school": school, "survey_item_responses.academic_year": academic_year)
@ -80,6 +80,6 @@ class SurveyItemResponse < ActiveRecord::Base
memo[[school, academic_year]] = hash memo[[school, academic_year]] = hash
end end
@student_survey_items_with_sufficient_responses_by_grade[[school, academic_year]] @student_survey_items_with_responses_by_grade[[school, academic_year]]
end end
end end

Loading…
Cancel
Save