Skip to content

Instantly share code, notes, and snippets.

@bradical
Created December 13, 2011 18:45
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 bradical/1473303 to your computer and use it in GitHub Desktop.
Save bradical/1473303 to your computer and use it in GitHub Desktop.
DelayedJob ActiveRecord Queries
# Output failed jobs by id with the delayed job type, associated ActiveRecord type, id, and method if applicable
Delayed::Job.where("failed_at is not null").select("id, handler, run_at, failed_at, last_error, job_type").order("id ASC").each { |j| puts "Id: #{j.id}\n DJ Type: #{$1 if j.handler =~ /!ruby\/struct:Delayed::(\w*) \n/}\n Failed at: #{j.failed_at}\n Object type: #{$1 if j.handler =~ /\nobject: !ruby\/(.*?)\s*\n/}\n Object Id: #{$1.to_i if j.handler =~ / id: (\d*)\n/}\n Method Name: #{$1 if j.handler =~ /\nmethod_name: (.*)\n/}\n Size: #{j.handler.size}\n\n\n"}
# Failed jobs
Delayed::Job.where('failed_at is not null')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment