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



29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/solid_stack_web/failed_jobs_controller.rb', line 29

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
18
19
20
# File 'app/controllers/solid_stack_web/failed_jobs_controller.rb', line 3

def index
  @sort      = params[:sort].presence_in(sortable_columns) || "created_at"
  @direction = params[:direction] == "asc" ? "asc" : "desc"

  respond_to do |format|
    format.html do
      scope = ::SolidQueue::FailedExecution.includes(:job).references(:job).order(sort_expression)
      @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



41
42
43
44
45
# File 'app/controllers/solid_stack_web/failed_jobs_controller.rb', line 41

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

#showObject



22
23
24
25
26
27
# File 'app/controllers/solid_stack_web/failed_jobs_controller.rb', line 22

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