Class: Wurk::Stats::History
- Inherits:
-
Object
- Object
- Wurk::Stats::History
- 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
- #expired ⇒ Object
- #failed ⇒ Object
-
#initialize(days_previous, start_date = nil, pool: nil) ⇒ History
constructor
A new instance of History.
- #processed ⇒ Object
Constructor Details
#initialize(days_previous, start_date = nil, pool: nil) ⇒ History
Returns a new instance of History.
171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/wurk/stats.rb', line 171 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 # UTC, not `Date.today`: the writer (Launcher#write_stats) keys these # buckets off `Time.now.utc`, so a local civil date reads a day the # writer never wrote for whatever slice of each day the host's offset # spans — the newest bucket comes back 0 and the window is shifted. @start_date = start_date || ::Time.now.utc.to_date @pool = pool end |
Instance Method Details
#expired ⇒ Object
185 |
# File 'lib/wurk/stats.rb', line 185 def expired = date_stat_hash('expired') |
#failed ⇒ Object
184 |
# File 'lib/wurk/stats.rb', line 184 def failed = date_stat_hash('failed') |
#processed ⇒ Object
183 |
# File 'lib/wurk/stats.rb', line 183 def processed = date_stat_hash('processed') |