forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add index specifically supporting Submission.needs_grading
Change-Id: I9718a6f931f586b43c45f5505d0c6877eb3605ac Reviewed-on: https://gerrit.instructure.com/124526 Reviewed-by: Tyler Pickett <[email protected]> Tested-by: Jenkins Product-Review: Cody Cutrer <[email protected]> QA-Review: Cody Cutrer <[email protected]>
- Loading branch information
Showing
2 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
db/migrate/20170830204122_add_submissions_needs_grading_index.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class AddSubmissionsNeedsGradingIndex < ActiveRecord::Migration[5.0] | ||
tag :postdeploy | ||
disable_ddl_transaction! | ||
|
||
def change | ||
# see Submission.needs_grading; duplicated instead of called directly so the migration doesn't | ||
# change even if the query does | ||
add_index :submissions, :assignment_id, name: 'index_submissions_needs_grading', algorithm: :concurrently, where: <<-SQL | ||
submissions.submission_type IS NOT NULL | ||
AND (submissions.excused = 'f' OR submissions.excused IS NULL) | ||
AND (submissions.workflow_state = 'pending_review' | ||
OR (submissions.workflow_state IN ('submitted', 'graded') | ||
AND (submissions.score IS NULL OR NOT submissions.grade_matches_current_submission) | ||
) | ||
) | ||
SQL | ||
end | ||
end |