Last active
August 29, 2015 13:57
Revisions
-
Koronen revised this gist
Jun 9, 2015 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,14 @@ puts fbe.map { |e,jj| [e, jj.size] }.inspect puts fbc.map { |e,jj| [e, jj.size] }.inspect # Dump failures as JSON failures = Resque::Failure.all(0, -1).each_with_index.map { |ex, i| ex['id'] = i; ex }; nil File.open("resque_failures_#{Time.now.strftime("%FT%T")}.json", 'wb') { |f| f.write JSON.dump(failures) } # Dump low queue as JSON low = Resque.redis.lrange 'queue:low', 0, -1; nil File.open("low_#{Time.now.strftime("%FT%T")}.json", "wb") { |f| f.write JSON.dump(low.map{|x| JSON.parse(x)}) } # Remove duplicates(?) key = 'queue:low' members = Resque.redis.lrange(key, 0, -1) -
Koronen revised this gist
Jun 9, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ # Print statistics failures = Resque::Failure.all(0, -1).each_with_index.map { |ex, i| ex['id'] = i; ex }; nil fbe = Hash.new { |h, k| h[k] = Array.new } fbc = Hash.new { |h, k| h[k] = Array.new } failures.each { |ex| fbe[ex['exception']] << ex; fbc[ex['payload']['class']] << ex }; nil puts fbe.map { |e,jj| [e, jj.size] }.inspect puts fbc.map { |e,jj| [e, jj.size] }.inspect # Dump as JSON failures = Resque::Failure.all(0, -1).each_with_index.map { |ex, i| ex['id'] = i; ex }; nil File.open("resque_failures_#{Time.now.strftime("%FT%T")}.json", 'wb') { |f| f.write JSON.dump(failures) } # Remove duplicates(?) key = 'queue:low' -
Koronen revised this gist
Feb 3, 2015 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,4 +8,16 @@ # Dump as JSON failures = Resque::Failure.all(0,9999).each_with_index.map { |ex, i| ex['id'] = i; ex }; nil File.open("resque_failures_#{Time.now.iso8601}.json", 'wb') { |f| f.write JSON.dump(failures) } # Remove duplicates(?) key = 'queue:low' members = Resque.redis.lrange(key, 0, -1) duplicate_members = members.group_by { |e| e }.select { |k, v| v.size > 1 }.map(&:first) if duplicate_members.count > 0 puts "#{key}: has #{duplicate_members.count} duplicates" duplicate_members.each do |duplicate_member| puts "Removing #{duplicate_member}" Resque.redis.lrem(key, -1, duplicate_member) end end -
Koronen revised this gist
Jan 13, 2015 . 1 changed file with 6 additions and 25 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,11 @@ # Print statistics failures = Resque::Failure.all(0,9999).each_with_index.map { |ex, i| ex['id'] = i; ex }; nil fbe = Hash.new { |h, k| h[k] = Array.new } fbc = Hash.new { |h, k| h[k] = Array.new } failures.each { |ex| fbe[ex['exception']] << ex; fbc[ex['payload']['class']] << ex }; nil puts fbe.map { |e,jj| [e, jj.size] }.inspect puts fbc.map { |e,jj| [e, jj.size] }.inspect # Dump as JSON failures = Resque::Failure.all(0,9999).each_with_index.map { |ex, i| ex['id'] = i; ex }; nil File.open("resque_failures_#{Time.now.iso8601}.json", 'wb') { |f| f.write JSON.dump(failures) } -
Koronen revised this gist
Dec 31, 2014 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,11 @@ def group_by_class(failures) def value_counts(grouped_failures) Hash[grouped_failures.map { |key, exs| [key, exs.size] }] end failures = Resque::Failure.all(0,9999).each_with_index.map { |ex, i| ex['id'] = i; ex }; nil fbe = Hash.new { |h, k| h[k] = Array.new } fbc = Hash.new { |h, k| h[k] = Array.new } failures.each { |ex| fbe[ex['exception']] << ex; fbc[ex['payload']['class']] << ex }; nil puts fbe.map { |e,jj| [e, jj.size] }.inspect puts fbc.map { |e,jj| [e, jj.size] }.inspect -
Koronen revised this gist
Mar 24, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,5 +19,5 @@ def group_by_class(failures) end def value_counts(grouped_failures) Hash[grouped_failures.map { |key, exs| [key, exs.size] }] end -
Koronen revised this gist
Mar 24, 2014 . 1 changed file with 21 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,23 @@ 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 -
Koronen created this gist
Mar 24, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ failures_with_ids = Resque::Failure.all(0,13000).each_with_index.map { |ex, i| ex['id'] = i; ex } failure_grouped_by_exception = failures_with_ids.reduce({}){|acc, ex| acc[ex['exception']] ||= []; acc[ex['exception']] << ex; acc } failure_grouped_by_class = failures_with_ids.reduce({}){|acc, ex| acc[ex['payload']['class']] ||= []; acc[ex['payload']['class']] << ex; acc }