Class: SolidQueueWeb::JobsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/solid_queue_web/jobs_controller.rb

Constant Summary collapse

STATUSES =
%w[ready scheduled claimed blocked failed].freeze

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/solid_queue_web/jobs_controller.rb', line 5

def index
  @status = params[:status].presence_in(STATUSES) || "ready"
  @queue  = params[:queue].presence

  @jobs = case @status
  when "ready"     then SolidQueue::ReadyExecution.includes(:job)
  when "scheduled" then SolidQueue::ScheduledExecution.includes(:job)
  when "claimed"   then SolidQueue::ClaimedExecution.includes(:job)
  when "blocked"   then SolidQueue::BlockedExecution.includes(:job)
  when "failed"    then SolidQueue::FailedExecution.includes(:job)
  end

  @jobs = @jobs.where(jobs: { queue_name: @queue }) if @queue.present?
  @jobs = @jobs.order(created_at: :desc).limit(100)
end