Sha256: bf160ba69704d0c7dfbaf5272de980e2b405d060c45f3ba90b1a70f839dcbe0b

Contents?: true

Size: 906 Bytes

Versions: 1

Compression:

Stored size: 906 Bytes

Contents

require 'sidekiq/web'

module Sidetiq
  module Web
    VIEWS = File.expand_path('views', File.dirname(__FILE__))

    def self.registered(app)
      app.get "/sidetiq" do
        clock = Sidetiq::Clock.instance
        @schedules = clock.schedules
        @time = clock.gettime
        slim File.read(File.join(VIEWS, 'sidetiq.slim'))
      end

      app.get "/sidetiq/:name" do
        halt 404 unless (name = params[:name])

        clock = Sidetiq::Clock.instance
        schedules = clock.schedules

        @time = clock.gettime

        @worker, @schedule = schedules.select do |worker, schedule|
          worker.name == name
        end.flatten

        slim File.read(File.join(VIEWS, 'sidetiq_details.slim'))
      end
    end
  end
end

Sidekiq::Web.register(Sidetiq::Web)

if Sidekiq::Web.tabs.is_a?(Array)
  Sidekiq::Web.tabs << "sidetiq"
else
  Sidekiq::Web.tabs["Sidetiq"] = "sidetiq"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidetiq-0.1.4 lib/sidetiq/web.rb