Last active
August 29, 2015 13:57
-
-
Save Koronen/9738152 to your computer and use it in GitHub Desktop.
Resque statistics hacks
This file contains hidden or 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 failures_with_ids(n) | |
Resque::Failure.all(0,n).each_with_index.map { |ex, i| ex['id'] = i; ex } | |
end | |
def group_by_exception(failures) | |
failures.reduce({}) do |acc, ex| | |
acc[ex['exception']] ||= [] | |
acc[ex['exception']] << ex | |
acc | |
end | |
end | |
def group_by_class(failures) | |
failures.reduce({}) do |acc, ex| | |
acc[ex['payload']['class']] ||= [] | |
acc[ex['payload']['class']] << ex | |
acc | |
end | |
end | |
def value_counts(grouped_failures) | |
Hash[grouped_failure.map { |key, exs| [key, exs.size] }] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment