Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should handle this when you create the job:<pre><code> priority = 0 run_time = my_object.start_time Delayed::Job.enqueue(MyCustomJob.new(my_object), priority, run_time) </code></pre></p> <p><a href="https://github.com/tobi/delayed_job/wiki" rel="nofollow noreferrer">https://github.com/tobi/delayed_job/wiki</a></p> <p>If your jobs aren't running at the expected time, you may be scheduling them for UTC:</p> <p><a href="http://www.gregbenedict.com/2009/08/19/is-delayed-job-run_at-datetime-giving-you-fits/" rel="nofollow noreferrer">http://www.gregbenedict.com/2009/08/19/is-delayed-job-run_at-datetime-giving-you-fits/</a></p> <p>To check the queue for an existing job - you could do the following:</p> <pre><code> class MyCustomJob &lt; Struct.new(:object_id) def self.exists?(object_id) Delayed::Job.where(['handler = ? and failed_at is null',handler(object_id)]).count(:all) > 0 end def self.handler(object_id) "--- !ruby/struct:MyCustomJob \nobject_id: #{object_id}\n" end def perform my_object = MyObject.find(object_id) my_object.do_stuff end end </code></pre> <p>Then just check for <code>MyCustomJob.exists?(my_object.id)</code> before queueing.</p> <p>It's a little bit of a hack - edit the <code>handler</code> method as needed. I would modify the delayed_jobs table to have a class/object_id to make for cleaner code and more efficient table scans if your jobs table is large or if you do this with other types of jobs.</p> <p>This question also looks relevant:</p> <p><a href="https://stackoverflow.com/questions/3638250/how-to-cancel-scheduled-job-with-delayed-job-in-rails">How to cancel scheduled job with delayed_job in Rails?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload