1
0
Fork 0
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:
Jason Harbert 2013-04-16 12:43:24 -07:00
parent d180cc13be
commit cbc2df1449
2 changed files with 11 additions and 0 deletions

View file

@ -279,6 +279,10 @@ module Sidekiq
end
end
def find_job(jid)
self.find{ |j| j.jid == jid }
end
def delete(score, jid = nil)
if jid
elements = Sidekiq.redis do |conn|

View file

@ -179,6 +179,13 @@ class TestApi < MiniTest::Unit::TestCase
assert_equal 0, q.size
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
q = Sidekiq::Queue.new
2.times { ApiWorker.perform_async(1, 'mike') }