mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
adding functionality to return job from a sorted set given a job id
This commit is contained in:
parent
d180cc13be
commit
cbc2df1449
2 changed files with 11 additions and 0 deletions
|
@ -279,6 +279,10 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_job(jid)
|
||||||
|
self.find{ |j| j.jid == jid }
|
||||||
|
end
|
||||||
|
|
||||||
def delete(score, jid = nil)
|
def delete(score, jid = nil)
|
||||||
if jid
|
if jid
|
||||||
elements = Sidekiq.redis do |conn|
|
elements = Sidekiq.redis do |conn|
|
||||||
|
|
|
@ -179,6 +179,13 @@ class TestApi < MiniTest::Unit::TestCase
|
||||||
assert_equal 0, q.size
|
assert_equal 0, q.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'can find job by id' do
|
||||||
|
q = Sidekiq::Queue.new
|
||||||
|
job_id = ApiWorker.perform_in(100, 1, 'jason')
|
||||||
|
job = Sidekiq::ScheduledSet.new.find_job(job_id)
|
||||||
|
assert job
|
||||||
|
end
|
||||||
|
|
||||||
it 'can clear a queue' do
|
it 'can clear a queue' do
|
||||||
q = Sidekiq::Queue.new
|
q = Sidekiq::Queue.new
|
||||||
2.times { ApiWorker.perform_async(1, 'mike') }
|
2.times { ApiWorker.perform_async(1, 'mike') }
|
||||||
|
|
Loading…
Reference in a new issue