desc 'Clear all Sidekiq queues'
task clear_sidekiq: :environment do
  sets = [
    Sidekiq::Queue,
    Sidekiq::ScheduledSet,
    Sidekiq::RetrySet,
    Sidekiq::DeadSet
  ]

  sets.each do |set|
    puts set
    puts set.new.clear
  end
end

desc 'Clear all Sidekiq queues'
task clear_sidekiq: :environment do
  queues = Sidekiq::Queue.all

  named_queues = [
    Sidekiq::ScheduledSet.new,
    Sidekiq::RetrySet.new,
    Sidekiq::DeadSet.new
  ]

  [queues + named_queues].each do |queue|
    puts queue
    puts queue.clear
  end
end

Improve task to clear Sidekiq
Improve task to clear Sidekiq

When I first wrote this we only used the default queue, but now that we
have the export queue, this needed some improving. Now, this will work
no matter how many queues we use.
