/delayed_jobs: add run, cancel, retry, delete actions.
This commit is contained in:
@@ -1,7 +1,41 @@
|
||||
class DelayedJobsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
respond_to :html, :xml, :json, :js
|
||||
before_filter :admin_only, except: [:index]
|
||||
|
||||
def index
|
||||
@delayed_jobs = Delayed::Job.order("created_at desc").paginate(params[:page], :limit => params[:limit])
|
||||
respond_with(@delayed_jobs)
|
||||
end
|
||||
|
||||
def cancel
|
||||
@job = Delayed::Job.find(params[:id])
|
||||
if !@job.locked_at?
|
||||
@job.fail!
|
||||
end
|
||||
respond_with(@job)
|
||||
end
|
||||
|
||||
def retry
|
||||
@job = Delayed::Job.find(params[:id])
|
||||
if !@job.locked_at?
|
||||
@job.update({failed_at: nil, attempts: 0}, without_protection: true)
|
||||
end
|
||||
respond_with(@job)
|
||||
end
|
||||
|
||||
def run
|
||||
@job = Delayed::Job.find(params[:id])
|
||||
if !@job.locked_at?
|
||||
@job.update(run_at: Time.now)
|
||||
end
|
||||
respond_with(@job)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@job = Delayed::Job.find(params[:id])
|
||||
if !@job.locked_at?
|
||||
@job.destroy
|
||||
end
|
||||
respond_with(@job)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user