Class: Sidekiq::Throttled::Web::Stats
- Inherits:
-
Object
- Object
- Sidekiq::Throttled::Web::Stats
- 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
-
#initialize(strategy) ⇒ Stats
constructor
A new instance of Stats.
- #to_html ⇒ String
Constructor Details
#initialize(strategy) ⇒ Stats
Returns a new instance of Stats.
16 17 18 19 20 |
# File 'lib/sidekiq/throttled/web/stats.rb', line 16 def initialize(strategy) raise ArgumentError, "Can't handle dynamic strategies" if strategy&.dynamic? @strategy = strategy end |
Instance Method Details
#to_html ⇒ String
23 24 25 26 27 28 29 30 31 |
# File 'lib/sidekiq/throttled/web/stats.rb', line 23 def to_html return "" unless @strategy html = humanize_integer(@strategy.limit) << " jobs" html << " per " << humanize_duration(@strategy.period) if @strategy.respond_to?(:period) html << "<br />" << colorize_count(@strategy.count, @strategy.limit) end |