Class: Sidekiq::Throttled::Web::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/throttled/web/stats.rb

Overview

Throttle strategy stats generation helper

Constant Summary collapse

TIME_CONVERSION =
[
  [60 * 60 * 24,  "day",    "days"],
  [60 * 60,       "hour",   "hours"],
  [60,            "minute", "minutes"],
  [1,             "second", "seconds"]
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(strategy) ⇒ Stats



16
17
18
19
20
21
# File 'lib/sidekiq/throttled/web/stats.rb', line 16

def initialize(strategy)
  if strategy && strategy.dynamic?
    raise ArgumentError, "Can't handle dynamic strategies"
  end
  @strategy = strategy
end

Instance Method Details

#to_htmlString



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sidekiq/throttled/web/stats.rb', line 24

def to_html
  return "" unless @strategy

  html = humanize_integer(@strategy.limit) << " jobs"

  if @strategy.respond_to? :period
    html << " per " << humanize_duration(@strategy.period)
  end

  html << "<br />" << colorize_count(@strategy.count, @strategy.limit)
end