Class: Sidekiq::Statistic::Base
- Inherits:
-
Object
- Object
- Sidekiq::Statistic::Base
show all
- Defined in:
- lib/sidekiq/statistic/base.rb
Constant Summary
collapse
- KEY_SEPARATOR =
/(?<!:):(?!:)/
Instance Method Summary
collapse
Constructor Details
#initialize(days_previous, start_date = nil) ⇒ Base
Returns a new instance of Base.
8
9
10
11
|
# File 'lib/sidekiq/statistic/base.rb', line 8
def initialize(days_previous, start_date = nil)
@start_date = start_date || Time.now.utc.to_date
@end_date = @start_date - days_previous
end
|
Instance Method Details
#statistic_for(worker) ⇒ Object
13
14
15
|
# File 'lib/sidekiq/statistic/base.rb', line 13
def statistic_for(worker)
statistic_hash.map{ |h| h.values.first[worker] || {} }
end
|
#statistic_hash ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/sidekiq/statistic/base.rb', line 21
def statistic_hash
@redis_hash ||= Sidekiq.redis do |conn|
redis_hash = {}
get_statistic_hash(conn, redis_hash)
update_time_values(conn, redis_hash)
desired_dates.map { |key| result_hash(redis_hash, key) }
end
end
|
#worker_names ⇒ Object
17
18
19
|
# File 'lib/sidekiq/statistic/base.rb', line 17
def worker_names
@worker_names ||= statistic_hash.flat_map{ |h| h.values.first.keys }.uniq.sort
end
|