Module: SidekiqJobStats::WebExtension

Defined in:
lib/sidekiq_job_stats/web_extension.rb

Constant Summary collapse

ROOT =
File.expand_path('../web', __dir__)

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sidekiq_job_stats/web_extension.rb', line 9

def self.registered(app)
  app.helpers Helpers::Stats

  app.get '/job_stats' do
    @jobs = SidekiqJobStats::Statistic.find_all.sort

    render(:erb, File.read("#{ROOT}/views/job_stats.erb"))
  end

  app.get '/job_stats/job_history/:job_class' do
    @job_class = SidekiqJobStats::Statistic.find_all.find { |j| j.job_class.to_s == params[:job_class] }

    @start = 0
    @start = params[:start].to_i if params[:start]
    @limit = 100
    @limit = params[:limit].to_i if params[:limit]

    @histories = @job_class.job_histories(@start, @limit)
    @size = @job_class.histories_recorded

    render(:erb, File.read("#{ROOT}/views/job_histories.erb"))
  end

  app.settings.locales << File.expand_path('locales', ROOT)
end