Skip to content

Commit

Permalink
Limit workers count for contracts migration
Browse files Browse the repository at this point in the history
  • Loading branch information
leandroalemao committed Oct 16, 2024
1 parent 07e052f commit 73c664b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/services/migration/migrators/contract.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Migration::Migrators
class Contract < Base
INFRA_WORKER_COUNT = 1

SHARED_ATTRIBUTES = %w[
created_at
updated_at
Expand Down Expand Up @@ -30,6 +32,18 @@ def ecf_contracts
def dependencies
%i[course statement]
end

def number_of_workers
return 1 if record_count > 1000

super
end

def records_per_worker
return record_count if record_count > 1000

super
end
end

def call
Expand Down
2 changes: 2 additions & 0 deletions spec/services/migration/migrators/contract_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

RSpec.describe Migration::Migrators::Contract do
it_behaves_like "a migrator", :contract, %i[course statement] do
let(:records_per_worker_divider) { 2 }

def create_ecf_resource
cohort = create(:ecf_migration_cohort)
npq_lead_provider = create(:ecf_migration_npq_lead_provider)
Expand Down

0 comments on commit 73c664b

Please sign in to comment.