This may not be an exact fit, but it should point in the right direction:
def self.up create_table :delayed_jobs, :force => true do |table| table.integer :priority, :default => 0, :null => false table.integer :attempts, :default => 0, :null => false table.text :handler, :null => false table.text :last_error table.datetime :run_at table.datetime :locked_at table.datetime :failed_at table.string :locked_by table.string :queue table.timestamps end
So, you can add a status column to this table, then run such a query to capture the task and check its status before doing anything else.
Delayed::Job.where(queue: '<YOUR QUEUE>').where(id: params[:id]).status
How would you establish a status, you ask? Well, use the hook of success in deferred missions. It would look something like this:
def success(job) update_status('success') end private def update_status(status) job = Job.find job_id job.status = status job.save! end
Hope this helps!
source share