Sha256: 7c40ed5ff5e1fc7f7b332b9ed86a51c8e3caf8d5f5c75ae0ad3c01a595ef0a33

Contents?: true

Size: 710 Bytes

Versions: 8

Compression:

Stored size: 710 Bytes

Contents

module Sidekiq
  module Monitor
    module Api
      class QueuesController < ActionController::Base
        protect_from_forgery

        def show
          queue = params[:queue]
          render json: {}, status: 404 and return if queue.blank?

          status_counts = Sidekiq::Monitor::Job.where(queue: queue).count(group: 'status')
          ordered_status_counts = {}
          Job.statuses.each do |status|
            ordered_status_counts[status] = status_counts.has_key?(status) ? status_counts[status] : 0
          end
          response = {
            status_counts: ordered_status_counts
          }
          render json: response.to_json, status: :ok
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sidekiq_monitor-0.1.5 app/controllers/sidekiq/monitor/api/queues_controller.rb
sidekiq_monitor-0.1.4 app/controllers/sidekiq/monitor/api/queues_controller.rb
sidekiq_monitor-0.1.3 app/controllers/sidekiq/monitor/api/queues_controller.rb
sidekiq_monitor-0.1.2 app/controllers/sidekiq/monitor/api/queues_controller.rb
sidekiq_monitor-0.1.1 app/controllers/sidekiq/monitor/api/queues_controller.rb
sidekiq_monitor-0.0.9 app/controllers/sidekiq/monitor/api/queues_controller.rb
sidekiq_monitor-0.0.8 app/controllers/sidekiq/monitor/api/queues_controller.rb
sidekiq_monitor-0.0.7 app/controllers/sidekiq/monitor/api/queues_controller.rb