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

Returns a new instance of Stats.

Parameters:

  • strategy (Strategy::Concurrency, Strategy::Threshold)


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

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

Instance Method Details

#to_htmlString

Returns:

  • (String)


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

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