working on 2018 admin data

pull/1/head
Jared Cosulich 7 years ago
parent 2dd216ee25
commit a6385897ff

@ -37,7 +37,7 @@ class School < ApplicationRecord
school_category.update(school_id: school.id) school_category.update(school_id: school.id)
existing_school_category = school.school_categories.for(school_category.school, school_category.category).in(school_category.year) existing_school_category = school.school_categories.for(school_category.school, school_category.category).in(school_category.year)
if existing_school_category.present? if existing_school_category.present?
if existing_school_category.attempt_count == 0 if existing_school_category.attempt_count == 0 && existing_school_category.zscore.nil?
existing_school_category.destroy existing_school_category.destroy
else else
school_category.destroy school_category.destroy

@ -52,6 +52,8 @@ class SchoolCategory < ApplicationRecord
SchoolCategory.for(school, cc).in(year).valid SchoolCategory.for(school, cc).in(year).valid
end.flatten.compact end.flatten.compact
return {} if child_school_categories.blank?
average_zscore = nil average_zscore = nil
zscore_categories = child_school_categories.select { |csc| csc.zscore.present? } zscore_categories = child_school_categories.select { |csc| csc.zscore.present? }
if zscore_categories.length > 0 if zscore_categories.length > 0
@ -76,7 +78,7 @@ class SchoolCategory < ApplicationRecord
def sync_aggregated_responses def sync_aggregated_responses
return if ENV['BULK_PROCESS'] return if ENV['BULK_PROCESS']
update_attributes(chained_aggregated_responses) update_attributes(chained_aggregated_responses)
return if response_count == 0 return if response_count == 0 && zscore.nil?
if category.parent_category.present? if category.parent_category.present?
parent_school_category = SchoolCategory.for(school, category.parent_category).in(year).first parent_school_category = SchoolCategory.for(school, category.parent_category).in(year).first
if parent_school_category.nil? if parent_school_category.nil?

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save