Skip to content

Commit

Permalink
DEV: script to analyze status of sidekiq queue
Browse files Browse the repository at this point in the history
This returns a proper count of all queued jobs and finds potential dupes
  • Loading branch information
SamSaffron committed May 22, 2019
1 parent 5429c9b commit 1226474
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions script/analyze_sidekiq_queues.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require File.expand_path("../../config/environment", __FILE__)

queues = %w{default low ultra_low critical}.map { |name| Sidekiq::Queue.new(name) }.lazy.flat_map(&:lazy)

stats = Hash.new(0)

queues.each do |j|
stats[j.klass] += 1
end

stats.sort_by { |a, b| -b }.each do |name, count|
puts "#{name}: #{count}"
end

dupes = Hash.new([])
queues.each do |j|
key = "#{j.klass} #{j.args}"
dupes[key] << j
end

total = 0

dupes.each do |k, jobs|
next if jobs.length == 1
total += job.length - 1
puts "dupe found"
p jobs
end

puts
puts "#{total} dupelicate jobs found!"

0 comments on commit 1226474

Please sign in to comment.