Module: CoreDelayedJobsController

Includes:
CoreController
Defined in:
lib/app/controllers/concerns/core_delayed_jobs_controller.rb

Overview

Manage access to delayed jobs

Instance Method Summary collapse

Instance Method Details

#destroyObject

Destroy the selected delayed job



72
73
74
75
76
77
78
79
80
# File 'lib/app/controllers/concerns/core_delayed_jobs_controller.rb', line 72

def destroy
  authorize! :manage, delayed_job
  delayed_job.destroy!
  flash.now[:info] = 'DelayJob has been destroyed'
  redirect_to index_path
rescue StandardError => error
  log_controller_error error, true
  redirect_to index_path
end

#destroy_allObject

Destroy all jobs



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/app/controllers/concerns/core_delayed_jobs_controller.rb', line 23

def destroy_all
  authorize! :manage, Delayed::Backend::Mongoid::Job
  failed_only = params[:failed_only].eql?('true')
  Delayed::Backend::Mongoid::Job.each do |job|
    next if failed_only && !job.failed?

    job.destroy
  end
  flash.now[:info] = 'All DelayJobs has been destroyed'
  redirect_to index_path
rescue StandardError => error
  log_controller_error error, true
  redirect_to index_path
end

#indexObject

Show a list of jobs currently in the system



11
12
13
14
# File 'lib/app/controllers/concerns/core_delayed_jobs_controller.rb', line 11

def index
  authorize! :read, Delayed::Backend::Mongoid::Job
  @delayed_jobs = Delayed::Backend::Mongoid::Job.asc(%i[priority run_at]).limit(100)
end

#resubmitObject

Resubmit the delayed job via update method



59
60
61
62
63
64
65
66
67
# File 'lib/app/controllers/concerns/core_delayed_jobs_controller.rb', line 59

def resubmit
  authorize! :read, delayed_job
  delayed_job.resubmit
  flash.now[:info] = 'DelayJob has been resubmitted'
  redirect_to index_path
rescue StandardError => error
  log_controller_error error, true
  redirect_to index_path
end

#resubmit_allObject

Resubmit all jobs that have failed



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/app/controllers/concerns/core_delayed_jobs_controller.rb', line 41

def resubmit_all
  authorize! :read, Delayed::Backend::Mongoid::Job
  failed_only = params[:failed_only].eql?('true')
  Delayed::Backend::Mongoid::Job.each do |job|
    next if failed_only && !job.failed?

    job.resubmit
  end
  flash.now[:info] = 'All DelayJobs has been resubmitted'
  redirect_to index_path
rescue StandardError => error
  log_controller_error error, true
  redirect_to index_path
end

#showObject



16
17
18
# File 'lib/app/controllers/concerns/core_delayed_jobs_controller.rb', line 16

def show
  delayed_job
end