Module: Sidekiq::History::WebExtension

Defined in:
lib/sidekiq/history/web_extension.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sidekiq/history/web_extension.rb', line 6

def self.registered(app)
  app.get '/history' do
    @count = (params[:count] || 25).to_i
    (@current_page, @total_size, @messages) = page('history', params[:page], @count)
    @messages = @messages.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }

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

  app.post "/history/remove" do
    Sidekiq::History.reset_history(counter: params['counter'])
    redirect("#{root_path}history")
  end

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