meteor-job-collection icon indicating copy to clipboard operation
meteor-job-collection copied to clipboard

Update job delay

Open wallslide opened this issue 9 years ago • 2 comments

If I create a job with a two-hour delay, and an hour later wish to add an extra hour of delay, what is the best way to accomplish that?

wallslide avatar Feb 24 '16 05:02 wallslide

job.pause()
job.delay(<new delay>)
job.save()
job.resume()

vsivsi avatar Feb 24 '16 22:02 vsivsi

Of course the above answer doesn't really answer the details of how to add an "extra hour" specifically... :-)

job.doc.after contains a Date representing the time after which the job can run (calculated from the job.delay() / job.after() at the time the job was created). If you'd like to add an additional hour to the original delay, you can do so as:

job.pause()
job.after(new Date(job.doc.after.setHours(job.doc.after.getHours()+1)))
job.save()
job.resume()

vsivsi avatar Feb 24 '16 22:02 vsivsi