Created
November 27, 2014 10:56
-
-
Save diegodurs/744164f2b880acddba87 to your computer and use it in GitHub Desktop.
Delayed::Job Scopes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DelayedJobScopes | |
extend ActiveSupport::Concern | |
included do | |
scope :error, -> (error) { failed.where('last_error ILIKE (?)', "%#{error.strip}%") } | |
scope :failed, -> { where('last_error IS NOT NULL') } | |
scope :queues, -> (queues) { where(queue: queues) } | |
end | |
def id_in_args | |
regex = /args\D+(\d*)/ | |
match = regex.match(handler) | |
match[1] if match | |
end | |
end | |
Delayed::Job.send(:include, DelayedJobScopes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment