Class: SolidQueueWeb::RetryFailedJobsController

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

Constant Summary

Constants inherited from ApplicationController

ApplicationController::PERIOD_DURATIONS, ApplicationController::STAGGER_INTERVALS

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/solid_queue_web/retry_failed_jobs_controller.rb', line 5

def create
  executions = params[:id] ? [SolidQueue::FailedExecution.find(params[:id])] : filtered_scope.to_a
  jobs = executions.map(&:job)

  if params[:stagger].present? && executions.size > 1
    interval = STAGGER_INTERVALS[params[:stagger]]
    raise ArgumentError, "Invalid stagger interval." unless interval
    executions.each_with_index do |execution, i|
      execution.job.update!(scheduled_at: i.zero? ? nil : Time.current + (i * interval))
      execution.retry
    end
  else
    SolidQueue::FailedExecution.retry_all(jobs)
  end
  redirect_to failed_jobs_path(queue: @queue, q: @search, period: @period),
    notice: retry_notice(jobs.size)
rescue ArgumentError => e
  redirect_to failed_jobs_path, alert: e.message
rescue => e
  redirect_to failed_jobs_path, alert: "Could not retry job: #{e.message}"
end