Class: SolidStackWeb::FailedJobsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/solid_stack_web/failed_jobs_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::PERIOD_DURATIONS

Instance Method Summary collapse

Instance Method Details

#destroyObject



26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/solid_stack_web/failed_jobs_controller.rb', line 26

def destroy
  @execution = ::SolidQueue::FailedExecution.find(params[:id])
  @execution.job.destroy!
  @executions_remain = ::SolidQueue::FailedExecution.exists?
  @notice = "Job discarded."

  respond_to do |format|
    format.html { redirect_to failed_jobs_path }
    format.turbo_stream
  end
end

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/solid_stack_web/failed_jobs_controller.rb', line 3

def index
  respond_to do |format|
    format.html do
      scope = ::SolidQueue::FailedExecution.includes(:job).order(created_at: :desc)
      @error_class = params[:error_class].presence
      scope = scope.where(id: ids_for_error_class(@error_class)) if @error_class
      @pagy, @executions = pagy(scope)
    end
    format.csv do
      send_data failed_jobs_csv,
                filename: "failed-jobs-#{Date.today}.csv",
                type: "text/csv", disposition: "attachment"
    end
  end
end

#retryObject



38
39
40
41
42
# File 'app/controllers/solid_stack_web/failed_jobs_controller.rb', line 38

def retry
  execution = ::SolidQueue::FailedExecution.find(params[:id])
  execution.retry
  redirect_to failed_jobs_path, notice: "Job retried."
end

#showObject



19
20
21
22
23
24
# File 'app/controllers/solid_stack_web/failed_jobs_controller.rb', line 19

def show
  @execution = ::SolidQueue::FailedExecution.includes(:job).find(params[:id])
  @arguments = JSON.pretty_generate(@execution.job.arguments) if @execution.job.arguments.present?
rescue JSON::GeneratorError
  @arguments = @execution.job.arguments.to_s
end