touch the course in grade calculator less often

We invalidate the course cache by touching the course too often. This
can cause issues in the database at scale. This patchset only touches
the course once after all the calculator work is done.

closes TALLY-849

test plan:
 - specs pass

Change-Id: Id006b9618ab89c003bd2d4b354247036dca9ce09
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234082
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Keith Garner <kgarner@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
This commit is contained in:
Keith T. Garner 2020-04-14 14:55:43 -05:00 committed by Keith Garner
parent 56efa192bc
commit acaceb1a0d
1 changed files with 3 additions and 2 deletions

View File

@ -91,6 +91,9 @@ class GradeCalculator
user_ids.sort.in_groups_of(100, false) do |user_ids_group|
GradeCalculator.new(user_ids_group, course, opts).compute_and_save_scores
end
# Touch the course to naively expire the cache
Course.where(id: course_id).not_recently_touched.update_all(updated_at: Time.now.utc)
end
def submissions
@ -515,8 +518,6 @@ class GradeCalculator
return if joined_enrollment_ids.blank?
return if @grading_period && @grading_period.deleted?
@course.touch
save_scores_in_transaction
end