Class: Sidekiq::Stats::History
- Inherits:
-
Object
- Object
- Sidekiq::Stats::History
- Defined in:
- lib/sidekiq/api.rb
Class Method Summary collapse
Instance Method Summary collapse
- #failed ⇒ Object
-
#initialize(days_previous, start_date = nil) ⇒ History
constructor
A new instance of History.
- #processed ⇒ Object
Constructor Details
#initialize(days_previous, start_date = nil) ⇒ History
Returns a new instance of History.
52 53 54 55 |
# File 'lib/sidekiq/api.rb', line 52 def initialize(days_previous, start_date = nil) @days_previous = days_previous @start_date = start_date || Time.now.utc.to_date end |
Class Method Details
.cleanup ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/sidekiq/api.rb', line 65 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 Sidekiq.redis do |conn| processed_keys = conn.keys("stat:processed:*") earliest = "stat:processed:#{delete_before_date.to_s}" pkeys = processed_keys.select { |key| key < earliest } conn.del(pkeys) if pkeys.size > 0 failed_keys = conn.keys("stat:failed:*") earliest = "stat:failed:#{delete_before_date.to_s}" fkeys = failed_keys.select { |key| key < earliest } conn.del(fkeys) if fkeys.size > 0 end end |
Instance Method Details
#failed ⇒ Object
61 62 63 |
# File 'lib/sidekiq/api.rb', line 61 def failed date_stat_hash("failed") end |
#processed ⇒ Object
57 58 59 |
# File 'lib/sidekiq/api.rb', line 57 def processed date_stat_hash("processed") end |