Sha256: 4ef1ff6f39f432b2313a7c69b88c444c8b5ea97b39890b7e1eba51d03b496b4f

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module AtomicSidekiq
  module Web
    VIEW_PATH = File.expand_path("../../web/views", __dir__)

    def self.registered(app)
      register_inflight(app)
      register_recovered(app)
    end

    def self.register_inflight(app)
      app.get "/in-flight" do
        @jobs = AtomicSidekiq::InFlightQueue.new.list
        @total_size = @jobs.count
        @count = (params[:count] || 25).to_i
        @current_page = (params[:page] || 1).to_i

        start_idx = (@current_page - 1) * @count
        end_idx = (@current_page * @count) - 1
        @jobs = @jobs[start_idx..end_idx]

        erb File.read(File.join(VIEW_PATH, "in_flight.erb"))
      end
    end

    def self.register_recovered(app)
      app.get "/recovered" do
        @queues = AtomicSidekiq::RecoveredStats.new.stats_by_queue
        @jobs = AtomicSidekiq::RecoveredStats.new.stats_by_job

        erb File.read(File.join(VIEW_PATH, "recovered.erb"))
      end
    end
  end
end

if defined?(Sidekiq::Web)
  Sidekiq::Web.register(AtomicSidekiq::Web)
  Sidekiq::Web.tabs["In-flight"] = "in-flight"
  Sidekiq::Web.tabs["Recovered"] = "recovered"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
atomic-sidekiq-1.2.0 lib/atomic_sidekiq/web.rb
atomic-sidekiq-1.1.4 lib/atomic_sidekiq/web.rb
atomic-sidekiq-1.1.3 lib/atomic_sidekiq/web.rb