diff --git a/lib/tasks/one_off.rake b/lib/tasks/one_off.rake index 6cfff744..02419628 100644 --- a/lib/tasks/one_off.rake +++ b/lib/tasks/one_off.rake @@ -145,10 +145,15 @@ namespace :one_off do School.all.each do |school| total = SurveyItemResponse.where(school:, academic_year:, survey_item: SurveyItem.student_survey_items).count.to_f + + respondent_count = SurveyItemResponse.where(school:, academic_year:, + survey_item: SurveyItem.student_survey_items).pluck(:response_id).uniq.count.to_f nil_count = SurveyItemResponse.where(school:, academic_year:, grade: nil, survey_item: SurveyItem.student_survey_items).count percentage = ((nil_count / total) * 100).round(1) - puts "#{percentage}% nil grades for: #{school.name}, #{academic_year.range}" if percentage > 10 + if percentage > 10 + puts "#{percentage}% nil grades out of #{respondent_count} students responding for: #{school.name}, #{academic_year.range}" + end end end end