Commit 316d8821 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Perform stage_id ref backgound migration in bulks

parent 00ca7481
...@@ -15,9 +15,9 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration ...@@ -15,9 +15,9 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
Build.where(stage_id: nil) Build.where(stage_id: nil)
.in_batches(of: BATCH_SIZE) do |relation, index| .in_batches(of: BATCH_SIZE) do |relation, index|
schedule = index * 5.minutes schedule = index * 5.minutes
relation.each do |build| jobs = relation.pluck(:id).map { |id| [MIGRATION, [id]] }
BackgroundMigrationWorker.perform_at(schedule, MIGRATION, [build.id])
end BackgroundMigrationWorker.perform_bulk_in(schedule, jobs)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment