1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Convert cleanup method to a class method.

This commit is contained in:
Brandon Hilkert 2012-12-09 15:17:53 -05:00
parent 0b1478d607
commit 2062963e20
2 changed files with 5 additions and 7 deletions

View file

@ -37,7 +37,6 @@ module Sidekiq
def initialize(days_previous, start_date = nil)
@days_previous = days_previous
@start_date = start_date || Time.now.utc.to_date
@days_of_stats_to_keep = 180
end
def processed
@ -48,9 +47,10 @@ module Sidekiq
date_stat_hash("failed")
end
def cleanup
def self.cleanup
days_of_stats_to_keep = 180
today = Time.now.utc.to_date
delete_before_date = Time.now.utc.to_date - @days_of_stats_to_keep
delete_before_date = Time.now.utc.to_date - days_of_stats_to_keep
Sidekiq.redis do |conn|
processed_keys = conn.keys("stat:processed:*")

View file

@ -124,8 +124,7 @@ class TestApi < MiniTest::Unit::TestCase
c.incrby("stat:processed:2012-07-03", 1)
end
Time.stub(:now, Time.parse("2012-12-01 1:00:00 -0500")) do
s = Sidekiq::Stats::History.new(0)
s.cleanup
Sidekiq::Stats::History.cleanup
assert_equal false, Sidekiq.redis { |c| c.exists("stat:processed:2012-05-03") }
end
end
@ -137,8 +136,7 @@ class TestApi < MiniTest::Unit::TestCase
c.incrby("stat:failed:2012-07-03", 1)
end
Time.stub(:now, Time.parse("2012-12-01 1:00:00 -0500")) do
s = Sidekiq::Stats::History.new(0)
s.cleanup
Sidekiq::Stats::History.cleanup
assert_equal false, Sidekiq.redis { |c| c.exists("stat:failed:2012-05-03") }
end
end