Skip to content

Instantly share code, notes, and snippets.

@diegodurs
Created November 27, 2014 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegodurs/744164f2b880acddba87 to your computer and use it in GitHub Desktop.
Save diegodurs/744164f2b880acddba87 to your computer and use it in GitHub Desktop.
Delayed::Job Scopes
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