Class: Toro::Monitor::Api::QueuesController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/toro/monitor/api/queues_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/toro/monitor/api/queues_controller.rb', line 7

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

  status_counts = Toro::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