Repository navigation
(via zetter-rpf): Use method-local batch in CreateAndAssignStudentsJob.enqueue_batches to avoid shared class-level state - #1134
Closed
macroscopeapp[bot] wants to merge 1 commit into
Closed
macroscopeapp[bot] wants to merge 1 commit into
macroscopeapp[bot] wants to merge 1 commit into
Conversation
…to avoid shared class-level state
|
We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please complete this form and we'll get you added and review your contribution as soon as possible. |
Test coverage94.19% line coverage reported by SimpleCov. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CreateAndAssignStudentsJob.enqueue_batchesnow keeps its batch in a method-localbatchvariable instead of the class-level@batchinstance variable.Why
@batchwas class-level, so every call toenqueue_batchesshared it. If two imports ran at the same time, one could overwrite the other's batch, and aUserJobrow could end up pointing at the wronggood_job_batch_id. With a local variable, each call has its own batch, and everyUserJobrow links to the batch that created it.Impact on callers
The only caller is
Api::SchoolClassesController. It already stores the method's return value in its own@batch, so it needs no changes.Verification
editor_checkreported no errors.Note
Macroscope: Fix It For Me
Activity
Currently: Closed by zetter-rpf
Previously