Commit 01128b13 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use integers to schedule delayed background migrations

parent 989785a3
...@@ -17,8 +17,8 @@ class BackgroundMigrationWorker ...@@ -17,8 +17,8 @@ class BackgroundMigrationWorker
# Schedules multiple jobs in bulk, with a delay. # Schedules multiple jobs in bulk, with a delay.
# #
def self.perform_bulk_in(delay, jobs) def self.perform_bulk_in(delay, jobs)
now = Time.now.to_f now = Time.now.to_i
schedule = now + delay.to_f schedule = now + delay.to_i
raise ArgumentError if schedule <= now raise ArgumentError if schedule <= now
......
...@@ -6,7 +6,7 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do ...@@ -6,7 +6,7 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
match do |migration| match do |migration|
BackgroundMigrationWorker.jobs.any? do |job| BackgroundMigrationWorker.jobs.any? do |job|
job['args'] == [migration, expected] && job['args'] == [migration, expected] &&
job['at'].to_f == (delay.to_f + Time.now.to_f) job['at'].to_f == (delay.to_i + Time.now.to_i)
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