diff --git a/app/presenters/analyze/graph/column/gender/score_for_gender.rb b/app/presenters/analyze/graph/column/gender/score_for_gender.rb index e904ce7c..4e1cad38 100644 --- a/app/presenters/analyze/graph/column/gender/score_for_gender.rb +++ b/app/presenters/analyze/graph/column/gender/score_for_gender.rb @@ -5,7 +5,8 @@ module Analyze module ScoreForGender def score(year_index) academic_year = academic_years[year_index] - averages = SurveyItemResponse.averages_for_gender(measure.student_survey_items, school, academic_year, gender) + averages = SurveyItemResponse.averages_for_gender(measure.student_survey_items, school, academic_year, + gender) average = bubble_up_averages(averages:) scorify(average:, meets_student_threshold: sufficient_student_responses?(academic_year:)) @@ -23,14 +24,17 @@ module Analyze return Score::NIL_SCORE unless meets_student_threshold Score.new(average:, - meets_teacher_threshold: false, - meets_student_threshold: true, - meets_admin_data_threshold: false) + meets_teacher_threshold: false, + meets_student_threshold: true, + meets_admin_data_threshold: false) end def sufficient_student_responses?(academic_year:) - yearly_counts = SurveyItemResponse.where(school: , academic_year: , gender:).group(:gender).select(:response_id).distinct(:response_id).count - yearly_counts.first[1] >= 10 + yearly_counts = SurveyItemResponse.where(school:, academic_year:, + gender:).group(:gender).select(:response_id).distinct(:response_id).count + yearly_counts.any? do |count| + count[1] >= 10 + end end end end