canvas-lms/app/models
Jeremy Stanley 5773e05c3c avoid excessive update-cached-due-date callbacks
deleting a user could cause thousands of update-cached-due-dates
jobs to be enqueued (one per assignment per enrollment; in the
referenced ticket, the test student had 13 enrollments and there
were 88 assignments, yielding 1,144 jobs, causing the request
to time out).

fix this by
 (1) using a batch job to update all assignments in the course,
     instead of a job per assignment
 (2) when deleting a user with multiple enrollments in a course,
     only run the update cached due date job once per course

test plan:
 0. run in "production" configuration (i.e., in QA portal)
 1. have a course with 10 sections and 100 assignments.
    I suggest creating these in the console, e.g.

    course = course.create! name: "CNVS-8068"
    10.times { |x| course.course_sections.create! name: "section #{x}" }
    100.times { |x| course.assignments.create! name: "assignment #{x}" }

 2. enter student view mode in this course
 3. reset the student view student
 4. verify 1000 jobs were not created (and the request doesn't time out)

fixes CNVS-8068

Change-Id: If00dd3197b70df42b0f9ec18303b02594861f69f
Reviewed-on: https://gerrit.instructure.com/25160
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-10-16 21:04:03 +00:00
..
broadcast_policies Extract Assignment Broadcast Policy 2013-06-04 18:11:44 +00:00
discussion_topic fix materialized views through pgbouncer 2013-08-06 22:10:32 +00:00
quiz_question fix relative margin of error for negative answer values 2013-10-15 19:48:53 +00:00
quiz_statistics clean up sorting all over 2013-10-02 21:38:08 +00:00
abstract_course.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
access_token.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
account.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
account_authorization_config.rb use the now-standard timeout_protection for ldap binding 2013-10-03 22:18:16 +00:00
account_notification.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
account_report.rb make account reports only run once and low priority 2013-09-17 18:33:58 +00:00
account_user.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
alert.rb use CANVAS_RAILS2 for conditionals 2013-10-10 15:58:43 +00:00
alert_criterion.rb alerts, closes #4317 2011-08-24 10:19:44 -06:00
announcement.rb fix permissions on imported announcements. 2013-08-13 02:18:55 +00:00
appointment_group.rb use unicode sorting for ruby and db stuff 2013-10-02 21:38:03 +00:00
appointment_group_context.rb multiple contexts per appointment group 2012-04-30 15:30:03 -06:00
appointment_group_sub_context.rb multiple contexts per appointment group 2012-04-30 15:30:03 -06:00
assessment_question.rb clean up sorting all over 2013-10-02 21:38:08 +00:00
assessment_question_bank.rb arel-ify scopes 2013-04-01 21:57:16 +00:00
assessment_question_bank_user.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
assessment_request.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
asset_user_access.rb arel-ify scopes 2013-04-01 21:57:16 +00:00
assignment.rb prevent teachers from unpublishing assignments with submissions 2013-10-16 19:33:47 +00:00
assignment_group.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
assignment_override.rb use CANVAS_RAILS2 for conditionals 2013-10-10 15:58:43 +00:00
assignment_override_student.rb arel-ify models 2013-04-01 18:42:38 +00:00
attachment.rb avoid :conditions argument to find, count, etc. 2013-10-14 19:29:27 +00:00
attachment_association.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
authorization_code.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
big_blue_button_conference.rb properly serialize empty recordings from BBB 2013-09-27 18:15:35 +00:00
bookmark_service.rb i18n Bookmark Service 2011-06-16 07:16:10 -06:00
calendar_event.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
cloned_item.rb make sure links in assessment questions are correctly translated, fixes #6012 2011-10-21 08:36:34 -06:00
collaboration.rb inline (and optimize) User.file_structure_for 2013-10-02 16:15:31 +00:00
collaborator.rb add groups to collaborators table, add api endpoint. 2013-01-04 20:18:04 -07:00
collection.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
collection_item.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
collection_item_data.rb get rspec 2 running with rails 3.0 2013-03-27 15:41:28 +00:00
collection_item_upvote.rb arel-ify models 2013-04-01 18:42:38 +00:00
communication_channel.rb convert app/models/mailer.rb for rails3 2013-10-15 21:17:42 +00:00
content_export.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
content_migration.rb fix quiz importing, re-importing, and overwriting 2013-10-04 16:52:35 +00:00
content_participation.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
content_participation_count.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
content_tag.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
context.rb clean up sorting all over 2013-10-02 21:38:08 +00:00
context_external_tool.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
context_module.rb don't create module progressions for users that aren't even in a course 2013-10-16 00:17:16 +00:00
context_module_item.rb change available_for? and locked_for? to be more consistent 2013-06-07 21:41:21 +00:00
context_module_progression.rb add framework for events to be triggered when a module is completed 2013-10-15 21:59:07 +00:00
context_module_sub_header.rb optimize AdheresToPolicy 2011-07-14 13:25:28 -06:00
conversation.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
conversation_batch.rb allow bulk messaging in new conversations 2013-09-24 00:29:53 +00:00
conversation_message.rb avoid :conditions argument to find, count, etc. 2013-10-14 19:29:27 +00:00
conversation_message_participant.rb add soft delete to conversation_message_participants 2013-08-08 16:00:51 +00:00
conversation_participant.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
course.rb avoid excessive update-cached-due-date callbacks 2013-10-16 21:04:03 +00:00
course_account_association.rb optimize Account#/Course.update_account_associations a bit 2013-06-07 14:47:09 +00:00
course_import.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
course_profile.rb context profiles, refs CNVS-2650 2013-02-01 17:57:07 -07:00
course_section.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
crocodoc_document.rb optimize CrocodocDocument.update_process_states 2013-08-22 19:12:15 +00:00
delayed_message.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
delayed_notification.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
designer_enrollment.rb straighten out course designer permissions 2012-01-13 18:56:50 -07:00
developer_key.rb use the birth shard so that the default shard can be changed 2013-05-07 15:44:17 +00:00
discussion_entry.rb use rails3 style validate/before_validation 2013-10-14 19:28:28 +00:00
discussion_entry_participant.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
discussion_topic.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
discussion_topic_participant.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
document_service.rb Initial commit. 2011-01-31 18:57:29 -07:00
enrollment.rb avoid excessive update-cached-due-date callbacks 2013-10-16 21:04:03 +00:00
enrollment_dates_override.rb term start/term end, rather than whenever 2011-09-13 15:20:15 -06:00
enrollment_term.rb avoid :conditions argument to find, count, etc. 2013-10-14 19:29:27 +00:00
eportfolio.rb handle ePortfolio name when too long 2013-09-05 17:26:04 +00:00
eportfolio_category.rb improve error handling for ePortfolio section editing 2013-09-11 20:36:14 +00:00
eportfolio_entry.rb remove some egregious usages of Enumerable#select when a query will do 2013-05-31 22:11:15 +00:00
error_report.rb use CANVAS_RAILS2 for conditionals 2013-10-10 15:58:43 +00:00
etherpad_collaboration.rb remove deprecated rails constant usage 2013-03-11 12:14:08 -06:00
external_feed.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
external_feed_entry.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
external_url.rb optimize AdheresToPolicy 2011-07-14 13:25:28 -06:00
favorite.rb arel-ify scopes 2013-04-01 21:57:16 +00:00
folder.rb use rails3 style validate/before_validation 2013-10-14 19:28:28 +00:00
google_docs_collaboration.rb Initial commit. 2011-01-31 18:57:29 -07:00
gradebook_upload.rb prepare for foreign keys refs #6895 2012-05-10 09:46:05 -06:00
grading_standard.rb use unicode sorting for ruby and db stuff 2013-10-02 21:38:03 +00:00
group.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
group_category.rb avoid excessive update-cached-due-date callbacks 2013-10-16 21:04:03 +00:00
group_membership.rb avoid excessive update-cached-due-date callbacks 2013-10-16 21:04:03 +00:00
ignore.rb arel-ify models 2013-04-01 18:42:38 +00:00
inbox_item.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
learning_outcome.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
learning_outcome_group.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
learning_outcome_result.rb simplify SimplyVersioned option storage and add callbacks 2013-04-20 13:20:29 +00:00
mailer.rb convert app/models/mailer.rb for rails3 2013-10-15 21:17:42 +00:00
media_object.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
media_track.rb Allow uploading subtitle tracks to videos 2013-02-01 12:53:16 -07:00
message.rb convert app/models/mailer.rb for rails3 2013-10-15 21:17:42 +00:00
migration_issue.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
notification.rb clean up sorting all over 2013-10-02 21:38:08 +00:00
notification_policy.rb use CANVAS_RAILS2 for conditionals 2013-10-10 15:58:43 +00:00
oauth_request.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
observer_enrollment.rb arel-ify models 2013-04-01 18:42:38 +00:00
open_object.rb simplify OpenStruct/OpenObject json serialization 2013-08-29 16:44:13 +00:00
page_comment.rb arel-ify scopes 2013-04-01 21:57:16 +00:00
page_view.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
plugin_setting.rb Revert "Revert "use the cached plugin settings to determine if enabled"" 2013-10-16 19:54:11 +00:00
profile.rb adds unlisted to the list of valid profile visibility values 2013-05-31 03:09:23 +00:00
progress.rb support tracking a delayed job in the Progress model 2013-07-10 14:11:48 +00:00
pseudonym.rb make pseudonyms.active scope more efficient 2013-08-07 17:40:44 +00:00
pseudonym_session.rb rails3 fixes 2013-06-26 20:22:26 +00:00
quiz.rb prevent teachers from unpublishing assignments with submissions 2013-10-16 19:33:47 +00:00
quiz_group.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
quiz_question.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
quiz_question_regrade.rb add the ability to regrade a quiz 2013-08-19 17:29:26 +00:00
quiz_regrade.rb add the ability to regrade a quiz 2013-08-19 17:29:26 +00:00
quiz_regrade_run.rb add the ability to regrade a quiz 2013-08-19 17:29:26 +00:00
quiz_statistics.rb only strand quiz_stats jobs per quiz 2013-06-05 17:22:07 +00:00
quiz_submission.rb clean up sorting all over 2013-10-02 21:38:08 +00:00
quiz_submission_snapshot.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
report_snapshot.rb arel-ify scopes 2013-04-01 21:57:16 +00:00
role.rb avoid :conditions argument to find, count, etc. 2013-10-14 19:29:27 +00:00
role_override.rb alerts are announcements 2013-07-29 15:14:13 +00:00
rubric.rb avoid :conditions argument to find, count, etc. 2013-10-14 19:29:27 +00:00
rubric_assessment.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
rubric_association.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
scribd_account.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
scribd_mime_type.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
session_persistence_token.rb fix session persistence tokens for out-of-shard users 2013-06-27 20:01:47 +00:00
setting.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
sis_batch.rb detect failed SIS jobs 2013-10-15 21:57:56 +00:00
stream_item.rb use CANVAS_RAILS2 for conditionals 2013-10-10 15:58:43 +00:00
stream_item_instance.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
student_enrollment.rb Minor fixes to StudentEnrollment associations. 2012-05-04 16:46:43 -06:00
student_view_enrollment.rb student view; closes #6995 2012-04-03 14:11:07 -06:00
submission.rb deprecate Setting.get_cached 2013-10-10 00:42:52 +00:00
submission_comment.rb per-instance json serialization methods/excludes 2013-08-29 22:39:17 +00:00
submission_comment_participant.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
submission_version.rb make submission version datafixup ignore yaml errors 2013-10-11 19:51:29 +00:00
ta_enrollment.rb straighten out course designer permissions 2012-01-13 18:56:50 -07:00
tableless.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
teacher_enrollment.rb straighten out course designer permissions 2012-01-13 18:56:50 -07:00
thumbnail.rb update thumbnail attachment options like Attachment's 2013-03-26 18:46:14 +00:00
user.rb avoid excessive update-cached-due-date callbacks 2013-10-16 21:04:03 +00:00
user_account_association.rb clean up user account associations 2013-01-31 10:41:55 -07:00
user_follow.rb use rails3 style validate/before_validation 2013-10-14 19:28:28 +00:00
user_note.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
user_observer.rb user co-enrollment backend work, closes #8588 2012-05-23 12:21:00 -06:00
user_profile.rb prevent text overflow for user_profile.title 2013-08-23 20:05:19 +00:00
user_profile_link.rb add data validation to user profile links 2012-09-24 15:38:26 -06:00
user_service.rb validate nullness in the db on a bunch of columns 2013-09-12 22:20:39 +00:00
web_conference.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
web_conference_participant.rb check all models for protecting attributes refs #3847 2011-05-25 17:38:50 -06:00
wiki.rb allow PUT requests to create wiki pages implicitly 2013-10-04 21:44:29 +00:00
wiki_page.rb remove unnecessary clone_for methods 2013-10-09 12:13:18 +00:00
wimba_conference.rb handle wimba conference date parsing in ruby18/ruby19. 2013-02-08 12:43:19 -07:00
zip_file_import.rb use the birth shard so that the default shard can be changed 2013-05-07 15:44:17 +00:00