Class: Sidekiq::Statistic::Realtime
- Inherits:
-
Base
- Object
- Base
- Sidekiq::Statistic::Realtime
show all
- Defined in:
- lib/sidekiq/statistic/statistic/realtime.rb
Constant Summary
collapse
- DAYS_PREVIOUS =
30
Constants inherited
from Base
Base::KEY_SEPARATOR
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#statistic_for, #statistic_hash, #worker_names
Constructor Details
Returns a new instance of Realtime.
12
13
14
15
|
# File 'lib/sidekiq/statistic/statistic/realtime.rb', line 12
def initialize
@start_date = Time.now.utc.to_date
@end_date = @start_date - DAYS_PREVIOUS
end
|
Class Method Details
.charts_initializer ⇒ Object
6
7
8
9
10
|
# File 'lib/sidekiq/statistic/statistic/realtime.rb', line 6
def self.charts_initializer
workers = new.worker_names.map{ |w| Array.new(12, 0).unshift(w) }
workers << Array.new(12) { |i| (Time.now - i).strftime('%T'.freeze) }.unshift('x'.freeze)
workers
end
|
Instance Method Details
#realtime_hash ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/sidekiq/statistic/statistic/realtime.rb', line 17
def realtime_hash
Sidekiq.redis do |conn|
redis_hash = {}
conn
.hgetall("#{REDIS_HASH}:realtime:#{Time.now.sec - 1}")
.each do |keys, value|
*keys, last = keys.split(KEY_SEPARATOR)
keys.inject(redis_hash, &key_or_empty_hash)[last] = value.to_i
end
redis_hash
end
end
|
#statistic(params = {}) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/sidekiq/statistic/statistic/realtime.rb', line 31
def statistic(params = {})
{
failed: { columns: columns_for('failed'.freeze, params) },
passed: { columns: columns_for('passed'.freeze, params) }
}
end
|