Skip to content

Instantly share code, notes, and snippets.

@carlosagp
Created November 29, 2017 17:39
Show Gist options
  • Save carlosagp/9dccf0ec1fbc359143d7abd64c38a4d4 to your computer and use it in GitHub Desktop.
Save carlosagp/9dccf0ec1fbc359143d7abd64c38a4d4 to your computer and use it in GitHub Desktop.
Delete Resque Jobs
def delete_mailer_jobs(number=10)
queue_name = 'mailer'
jobs = Resque.redis.lrange('queue:mailer', 0, number)
deleted_count = 0
jobs.each do |job|
decoded_job = Resque.decode(job)
if decoded_job['class'] == 'MailerQueue' && decoded_job['args'].include?('error_notification')
Resque::Job.destroy(queue_name, decoded_job['class'], *decoded_job['args'])
deleted_count += 1
# puts "Deleted!"
end
end
deleted_count
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment