From 3ab5af14a2e2ea9668b611f7b4bcf56b9f722161 Mon Sep 17 00:00:00 2001 From: Mark Chao Date: Wed, 19 Dec 2018 16:34:34 +0800 Subject: Check if specific type of background migration are done Useful for checking progress. --- lib/gitlab/background_migration.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/gitlab/background_migration.rb b/lib/gitlab/background_migration.rb index d72befce571..6cf40e2d4ca 100644 --- a/lib/gitlab/background_migration.rb +++ b/lib/gitlab/background_migration.rb @@ -51,6 +51,19 @@ module Gitlab migration_class_for(class_name).new.perform(*arguments) end + def self.exists?(migration_class) + enqueued = Sidekiq::Queue.new(self.queue) + scheduled = Sidekiq::ScheduledSet.new + + [enqueued, scheduled].each do |queue| + queue.each do |job| + return true if job.queue == self.queue && job.args.first == migration_class + end + end + + false + end + def self.migration_class_for(class_name) const_get(class_name) end -- cgit v1.2.3