Skip to content

Commit 3c05d40

Browse files
committed
Fix multiple top level classes rubocop error
Having things defined in the top level of files that don't match the class names can break the autoloader and lead to odd behaviour. I've merged the two uses of ConcurrencyExceededForSchool errors since they both refer to students.
1 parent 38dce4e commit 3c05d40

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

app/controllers/api/school_students_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def create_batch
8282
# should assume the entire student import has failed.
8383
def enqueue_batches(students)
8484
# Raise if a batch is already in progress for this school.
85-
raise ConcurrencyExceededForSchool if @school.import_in_progress?
85+
raise CreateStudentsJob::ConcurrencyExceededForSchool if @school.import_in_progress?
8686

8787
@batch = GoodJob::Batch.new(description: @school.id)
8888
@batch.enqueue do

app/jobs/create_students_job.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22

3-
class ConcurrencyExceededForSchool < StandardError; end
4-
53
class CreateStudentsJob < ApplicationJob
4+
class ConcurrencyExceededForSchool < StandardError; end
5+
66
retry_on StandardError, wait: :polynomially_longer, attempts: 3 do |_job, e|
77
Sentry.capture_exception(e)
88
raise e

lib/concepts/school_student/create_batch.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
module SchoolStudent
44
class Error < StandardError; end
55

6-
class ConcurrencyExceededForSchool < StandardError; end
7-
86
class CreateBatch
97
class << self
108
def call(school:, school_students_params:, token:)
119
response = OperationResponse.new
1210
response[:job_id] = create_batch(school, school_students_params, token)
1311
response
14-
rescue ConcurrencyExceededForSchool => e
12+
rescue CreateStudentsJob::ConcurrencyExceededForSchool => e
1513
response[:error] = e
1614
response[:error_type] = :job_concurrency_error
1715
response

0 commit comments

Comments
 (0)