You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sqm-dashboards/app/models/subcategory.rb

14 lines
312 B

class Subcategory < ActiveRecord::Base
belongs_to :category
has_many :measures
def score(school:, academic_year:)
scores = measures.includes([:survey_items]).map do |measure|
measure.score(school:, academic_year:).average
end
scores = scores.reject(&:nil?)
scores.average
end
end