Created
November 29, 2017 17:39
-
-
Save carlosagp/9dccf0ec1fbc359143d7abd64c38a4d4 to your computer and use it in GitHub Desktop.
Delete Resque Jobs
This file contains 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
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