Class: Wurk::Stats::History

Inherits:
Object
  • Object
show all
Defined in:
lib/wurk/stats.rb

Overview

Per-day historical processed/failed/expired counts. Reads ‘stat:processed:YYYY-MM-DD`, `stat:failed:YYYY-MM-DD`, and `stat:expired:YYYY-MM-DD` strings; missing days return 0. Range 1..1825 (5 years) mirrors upstream.

Constant Summary collapse

MAX_DAYS =
1_825

Instance Method Summary collapse

Constructor Details

#initialize(days_previous, start_date = nil, pool: nil) ⇒ History

Returns a new instance of History.

Raises:

  • (ArgumentError)


159
160
161
162
163
164
165
# File 'lib/wurk/stats.rb', line 159

def initialize(days_previous, start_date = nil, pool: nil)
  raise ArgumentError, "days_previous must be in 1..#{MAX_DAYS}" unless (1..MAX_DAYS).cover?(days_previous)

  @days_previous = days_previous
  @start_date    = start_date || ::Date.today
  @pool          = pool
end

Instance Method Details

#expiredObject



169
# File 'lib/wurk/stats.rb', line 169

def expired   = date_stat_hash('expired')

#failedObject



168
# File 'lib/wurk/stats.rb', line 168

def failed    = date_stat_hash('failed')

#processedObject



167
# File 'lib/wurk/stats.rb', line 167

def processed = date_stat_hash('processed')