fixing bug with aggregating school categories

This commit is contained in:
Jared Cosulich 2019-03-01 16:20:37 -05:00
parent 56157a612d
commit d6ef6cd037

View file

@ -55,14 +55,12 @@ class SchoolCategory < ApplicationRecord
return {} if child_school_categories.blank?
average_zscore = nil
zscore_categories = child_school_categories.select { |csc| csc.zscore.present? }
zscore_categories = child_school_categories.select { |csc| csc.zscore.present? && !csc.zscore.nan? }
if zscore_categories.length > 0
total_zscore = zscore_categories.inject(0) { |total, zc| total + zc.zscore }
average_zscore = total_zscore / zscore_categories.length
end
return {
attempt_count:
_aggregated_responses[:attempt_count] +