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
-
#destroy ⇒ Object
Destroy the selected delayed job.
-
#destroy_all ⇒ Object
Destroy all jobs.
-
#index ⇒ Object
Show a list of jobs currently in the system.
-
#resubmit ⇒ Object
Resubmit the delayed job via update method.
-
#resubmit_all ⇒ Object
Resubmit all jobs that have failed.
- #show ⇒ Object
Instance Method Details
#destroy ⇒ Object
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 :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_all ⇒ Object
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 :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 |
#index ⇒ Object
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 :read, Delayed::Backend::Mongoid::Job @delayed_jobs = Delayed::Backend::Mongoid::Job.asc(%i[priority run_at]).limit(100) end |
#resubmit ⇒ Object
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 :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_all ⇒ Object
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 :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 |
#show ⇒ Object
16 17 18 |
# File 'lib/app/controllers/concerns/core_delayed_jobs_controller.rb', line 16 def show delayed_job end |