only recache_grade_distribution if defined

fixes gh-1325

test plan
 - checkout canvas-lms and this commit with
   no plugins
 - run an enrollment sis import
 - it should pass

Change-Id: I9b93da6dec381ba19d103c468a712ec18db6b43e
Reviewed-on: https://gerrit.instructure.com/158443
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
Rob Orton 2018-07-23 22:43:37 -06:00
parent 94b425be50
commit 528399f09c
1 changed files with 6 additions and 4 deletions

View File

@ -44,10 +44,12 @@ module SIS
end
# We batch these up at the end because we don't want to keep touching the same course over and over,
# and to avoid hitting other callbacks for the course (especially broadcast_policy)
i.courses_to_touch_ids.to_a.in_groups_of(1000, false) do |batch|
courses = Course.where(id: batch)
courses.touch_all
courses.each(&:recache_grade_distribution)
if Course.method_defined?(:recache_grade_distribution)
i.courses_to_touch_ids.to_a.in_groups_of(1000, false) do |batch|
courses = Course.where(id: batch)
courses.touch_all
courses.each(&:recache_grade_distribution)
end
end
i.courses_to_recache_due_dates.to_a.in_groups_of(1000, false) do |batch|
batch.each do |course_id, user_ids|