mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
trying to fix merge_into
This commit is contained in:
parent
9032341290
commit
5902c2787f
1 changed files with 24 additions and 0 deletions
|
|
@ -48,7 +48,31 @@ class School < ApplicationRecord
|
|||
reload
|
||||
|
||||
user_schools.update_all(school_id: school.id)
|
||||
|
||||
school.school_categories.map(&:sync_aggregated_responses)
|
||||
|
||||
base_categories = Category.joins(:questions).to_a.flatten.uniq
|
||||
base_categories.each do |category|
|
||||
SchoolCategory.for(school, category).each do |school_category|
|
||||
dup_school_categories = SchoolCategory.for(school, category).in(year)
|
||||
if dup_school_categories.count > 1
|
||||
dup_school_categories.each { |dsc| dsc.destroy unless dsc.id == school_category.id }
|
||||
school_category.sync_aggregated_responses
|
||||
parent = category.parent_category
|
||||
while parent != nil
|
||||
SchoolCategory.for(school, parent).in(year).valid.each do |parent_school_category|
|
||||
parent_dup_school_categories = SchoolCategory.for(school, parent).in(year)
|
||||
if parent_dup_school_categories.count > 1
|
||||
parent_dup_school_categories.each { |pdsc| pdsc.destroy unless pdsc.id == parent_school_category.id }
|
||||
parent_school_category.sync_aggregated_responses
|
||||
end
|
||||
end
|
||||
parent = parent.parent_category
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
destroy
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue