From cd5230a1075ac207c30b4f789ffcfd02ec64add5 Mon Sep 17 00:00:00 2001 From: Chris Hoffman Date: Sun, 27 Jul 2014 23:15:46 -0400 Subject: [PATCH] add queues for stats and as a filter option --- lib/resque_cleaner.rb | 13 +++++++++++++ lib/resque_cleaner/server.rb | 18 +++++++++++++++++- lib/resque_cleaner/server/views/cleaner.erb | 9 +++++++++ .../server/views/cleaner_list.erb | 3 +++ test/resque_cleaner_test.rb | 6 ++++++ test/resque_web_test.rb | 2 ++ 6 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/resque_cleaner.rb b/lib/resque_cleaner.rb index 4a8148b..0469674 100644 --- a/lib/resque_cleaner.rb +++ b/lib/resque_cleaner.rb @@ -48,6 +48,19 @@ def stats_by_date(&block) stats end + # Stats by queue. + def stats_by_queue(&block) + jobs, stats = select(&block), {} + jobs.each do |job| + queue = job["queue"] || "UNKNOWN" + stats[queue] ||= 0 + stats[queue] += 1 + end + + print_stats(stats) if print? + stats + end + # Stats by class. def stats_by_class(&block) jobs, stats = select(&block), {} diff --git a/lib/resque_cleaner/server.rb b/lib/resque_cleaner/server.rb index f559ed6..a7ad292 100644 --- a/lib/resque_cleaner/server.rb +++ b/lib/resque_cleaner/server.rb @@ -80,6 +80,16 @@ def time_filter(id, name, value) html += "" end + def queue_filter(id, name, queues, value) + html = "" + end + def class_filter(id, name, klasses, value) html = "