Skip to content

(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
async-import-3from
macroscope/async-import-3
Closed

macroscopeapp[bot] wants to merge 1 commit into
async-import-3from
macroscope/async-import-3

Conversation

@macroscopeapp

@macroscopeapp macroscopeapp Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Summary

CreateAndAssignStudentsJob.enqueue_batches now keeps its batch in a method-local batch variable instead of the class-level @batch instance variable.

Why

@batch was class-level, so every call to enqueue_batches shared it. If two imports ran at the same time, one could overwrite the other's batch, and a UserJob row could end up pointing at the wrong good_job_batch_id. With a local variable, each call has its own batch, and every UserJob row 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_check reported no errors.
  • I haven't run the test suite on this change.

Note

Macroscope: Fix It For Me

Activity

Currently: Closed by zetter-rpf

Previously
  • Ready for review
  • Waiting on checks
  • Pushed 1b2ee76

@cla-bot

cla-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

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.

@macroscopeapp
macroscopeapp Bot requested a review from zetter-rpf November 24, 2026 14:21
@github-actions

Copy link
Copy Markdown

Test coverage

94.19% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/45413122619

@zetter-rpf zetter-rpf closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant