mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Add "Delete All" and "Retry All" buttons to retries on Web UI.
This commit is contained in:
parent
166edb8f68
commit
3758afba6a
6 changed files with 84 additions and 9 deletions
|
@ -5,6 +5,7 @@ HEAD
|
||||||
Sidekiq client does not have to load your worker classes at all. [#524]
|
Sidekiq client does not have to load your worker classes at all. [#524]
|
||||||
- `Sidekiq::Client.push_bulk` now works with inline testing.
|
- `Sidekiq::Client.push_bulk` now works with inline testing.
|
||||||
- **Really** fix status icon in Web UI this time.
|
- **Really** fix status icon in Web UI this time.
|
||||||
|
- Add "Delete All" and "Retry All" buttons to Retries in Web UI
|
||||||
|
|
||||||
|
|
||||||
2.5.3
|
2.5.3
|
||||||
|
|
|
@ -43,6 +43,15 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear
|
||||||
|
Sidekiq.redis do |conn|
|
||||||
|
conn.multi do
|
||||||
|
conn.del("queue:#{name}")
|
||||||
|
conn.srem("queues", name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -143,6 +152,12 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
count != 0
|
count != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear
|
||||||
|
Sidekiq.redis do |conn|
|
||||||
|
conn.del(@zset)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -136,10 +136,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
post "/queues/:name" do
|
post "/queues/:name" do
|
||||||
Sidekiq.redis do |conn|
|
Sidekiq::Queue.new(params[:name]).clear
|
||||||
conn.del("queue:#{params[:name]}")
|
|
||||||
conn.srem("queues", params[:name])
|
|
||||||
end
|
|
||||||
redirect "#{root_path}queues"
|
redirect "#{root_path}queues"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -195,6 +192,18 @@ module Sidekiq
|
||||||
redirect "#{root_path}retries"
|
redirect "#{root_path}retries"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post "/retries/all/delete" do
|
||||||
|
Sidekiq::RetrySet.new.clear
|
||||||
|
redirect "#{root_path}retries"
|
||||||
|
end
|
||||||
|
|
||||||
|
post "/retries/all/retry" do
|
||||||
|
Sidekiq::RetrySet.new.each do |job|
|
||||||
|
process_score('retry', job.score, :retry)
|
||||||
|
end
|
||||||
|
redirect "#{root_path}retries"
|
||||||
|
end
|
||||||
|
|
||||||
post "/retries/:score" do
|
post "/retries/:score" do
|
||||||
halt 404 unless params[:score]
|
halt 404 unless params[:score]
|
||||||
score = params[:score].to_f
|
score = params[:score].to_f
|
||||||
|
|
|
@ -36,6 +36,17 @@ class TestApi < MiniTest::Unit::TestCase
|
||||||
assert_equal 0, q.size
|
assert_equal 0, q.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'can clear a queue' do
|
||||||
|
q = Sidekiq::Queue.new
|
||||||
|
2.times { ApiWorker.perform_async(1, 'mike') }
|
||||||
|
q.clear
|
||||||
|
|
||||||
|
Sidekiq.redis do |conn|
|
||||||
|
refute conn.smembers('queues').include?('foo')
|
||||||
|
refute conn.exists('queues:foo')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'shows empty retries' do
|
it 'shows empty retries' do
|
||||||
r = Sidekiq::RetrySet.new
|
r = Sidekiq::RetrySet.new
|
||||||
assert_equal 0, r.size
|
assert_equal 0, r.size
|
||||||
|
@ -64,9 +75,18 @@ class TestApi < MiniTest::Unit::TestCase
|
||||||
assert_equal 0, r.size
|
assert_equal 0, r.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_retry
|
it 'can clear retries' do
|
||||||
|
add_retry
|
||||||
|
add_retry('test')
|
||||||
|
r = Sidekiq::RetrySet.new
|
||||||
|
assert_equal 2, r.size
|
||||||
|
r.clear
|
||||||
|
assert_equal 0, r.size
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_retry(jid = 'bob')
|
||||||
at = Time.now.to_f
|
at = Time.now.to_f
|
||||||
payload = Sidekiq.dump_json('class' => 'ApiWorker', 'args' => [1, 'mike'], 'queue' => 'default', 'jid' => 'bob')
|
payload = Sidekiq.dump_json('class' => 'ApiWorker', 'args' => [1, 'mike'], 'queue' => 'default', 'jid' => jid)
|
||||||
Sidekiq.redis do |conn|
|
Sidekiq.redis do |conn|
|
||||||
conn.zadd('retry', at.to_s, payload)
|
conn.zadd('retry', at.to_s, payload)
|
||||||
end
|
end
|
||||||
|
|
|
@ -72,6 +72,7 @@ class TestWeb < MiniTest::Unit::TestCase
|
||||||
|
|
||||||
Sidekiq.redis do |conn|
|
Sidekiq.redis do |conn|
|
||||||
refute conn.smembers('queues').include?('foo')
|
refute conn.smembers('queues').include?('foo')
|
||||||
|
refute conn.exists('queues:foo')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -154,6 +155,15 @@ class TestWeb < MiniTest::Unit::TestCase
|
||||||
refute_match /#{score}/, last_response.body
|
refute_match /#{score}/, last_response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'can delete all retries' do
|
||||||
|
3.times { add_retry }
|
||||||
|
|
||||||
|
post "/retries/all/delete", 'delete' => 'Delete'
|
||||||
|
assert_equal 0, Sidekiq::RetrySet.new.size
|
||||||
|
assert_equal 302, last_response.status
|
||||||
|
assert_equal 'http://example.org/retries', last_response.header['Location']
|
||||||
|
end
|
||||||
|
|
||||||
it 'can retry a single retry now' do
|
it 'can retry a single retry now' do
|
||||||
msg, score = add_retry
|
msg, score = add_retry
|
||||||
|
|
||||||
|
@ -166,6 +176,20 @@ class TestWeb < MiniTest::Unit::TestCase
|
||||||
assert_match /#{msg['args'][2]}/, last_response.body
|
assert_match /#{msg['args'][2]}/, last_response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'can retry all retries' do
|
||||||
|
msg, score = add_retry
|
||||||
|
add_retry
|
||||||
|
|
||||||
|
post "/retries/all/retry", 'retry' => 'Retry'
|
||||||
|
assert_equal 302, last_response.status
|
||||||
|
assert_equal 'http://example.org/retries', last_response.header['Location']
|
||||||
|
assert_equal 2, Sidekiq::Queue.new("default").size
|
||||||
|
|
||||||
|
get '/queues/default'
|
||||||
|
assert_equal 200, last_response.status
|
||||||
|
assert_match /#{msg['args'][2]}/, last_response.body
|
||||||
|
end
|
||||||
|
|
||||||
it 'can show user defined tab' do
|
it 'can show user defined tab' do
|
||||||
begin
|
begin
|
||||||
Sidekiq::Web.tabs['Custom Tab'] = '/custom'
|
Sidekiq::Web.tabs['Custom Tab'] = '/custom'
|
||||||
|
|
|
@ -28,7 +28,13 @@ header.row
|
||||||
a href="#{root_path}queues/#{msg['queue']}" #{msg['queue']}
|
a href="#{root_path}queues/#{msg['queue']}" #{msg['queue']}
|
||||||
td= msg['class']
|
td= msg['class']
|
||||||
td= display_args(msg['args'])
|
td= display_args(msg['args'])
|
||||||
input.btn.btn-danger.btn-small.pull-right type="submit" name="delete" value="Delete"
|
input.btn.btn-primary.btn-small.pull-left type="submit" name="retry" value="Retry Now"
|
||||||
input.btn.btn-primary.btn-small.pull-right type="submit" name="retry" value="Retry Now"
|
input.btn.btn-danger.btn-small.pull-left type="submit" name="delete" value="Delete"
|
||||||
|
|
||||||
|
form action="#{root_path}retries/all/delete" method="post"
|
||||||
|
input.btn.btn-danger.btn-small.pull-right type="submit" name="delete" value="Delete All" data-confirm="Are you sure?"
|
||||||
|
form action="#{root_path}retries/all/retry" method="post"
|
||||||
|
input.btn.btn-danger.btn-small.pull-right type="submit" name="retry" value="Retry All" data-confirm="Are you sure?"
|
||||||
|
|
||||||
- else
|
- else
|
||||||
.alert.alert-success No retries were found
|
.alert.alert-success No retries were found
|
||||||
|
|
Loading…
Add table
Reference in a new issue