Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #69 from joshsoftware/issue-17
Browse files Browse the repository at this point in the history
Fixed unschedule(nil) bug - fixes #17
  • Loading branch information
utgarda committed Dec 6, 2015
2 parents f3784c7 + b52e2e2 commit 0849e56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ Sidekiq::Status::pct_complete job_id #=> 5
```ruby
scheduled_job_id = MyJob.perform_in 3600
Sidekiq::Status.cancel scheduled_job_id #=> true
#doesn't cancel running jobs, this is more like unscheduling, therefore an alias:
# doesn't cancel running jobs, this is more like unscheduling, therefore an alias:
Sidekiq::Status.unschedule scheduled_job_id #=> true

# returns false if invalid or wrong scheduled_job_id is provided
Sidekiq::Status.unschedule some_other_unschedule_job_id #=> false
Sidekiq::Status.unschedule nil #=> false
Sidekiq::Status.unschedule '' #=> false
# Note: cancel and unschedule are alias methods.
```

### Sidekiq web integration
Expand Down
3 changes: 1 addition & 2 deletions lib/sidekiq-status/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ def scan_scheduled_jobs_for_jid(scheduled_jobs, job_id)
# A Little skecthy, I know, but the structure of these internal JSON
# is predefined in such a way where this will not catch unintentional elements,
# and this is notably faster than performing JSON.parse() for every listing:
scheduled_jobs.each { |job_listing| (return job_listing) if job_listing.include?("\"jid\":\"#{job_id}") }
nil
scheduled_jobs.select { |job_listing| job_listing.match(/\"jid\":\"#{job_id}\"/) }[0]
end

# Yields redis connection. Uses redis pool if available.
Expand Down

0 comments on commit 0849e56

Please sign in to comment.