Created
March 15, 2012 15:55
-
-
Save jrom/2044930 to your computer and use it in GitHub Desktop.
Remove resque jobs if match a condition
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 remove_failed_jobs_if(&block) | |
i = 0 | |
while i < Resque::Failure.count | |
job = Resque::Failure.all(i) | |
if yield job | |
Resque::Failure.remove(i) | |
else | |
i += 1 | |
end | |
end | |
end | |
# Example usage | |
remove_failed_jobs_if { |job| job['queue'] == 'cache_warmer' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment