jmettraux/rufus-scheduler

past date/time jobs are run immediately

jasonwbarnett opened this issue ยท 6 comments

First off, thanks for writing and maintaining this project. It's a pretty nifty library.

I wanted to provide that feedback that it caught me by surprise that if I use scheduler.at for a date/time in the past it runs that job immediately. You're first question may be, "Why are you using a scheduler for a past date/time? Great question, I'm so glad you asked. I have a simple application that is continuously deployed and there are a bunch of date/times in a YAML file that are used to scheduled jobs around. Some of these date/times are in the past and that's OK. I am dynamically running a loop to create scheduled jobs. I was able to tactically resolve this by guarding the schedule creation with next if time < Time.now but again, I mostly wanted to post this to give feedback that it caught me by surprise. My expectation (not asserting it's right or wrong) is that any attempt to schedule a job using a date/time that has already passed would just be discarded with a warning or something.

Thanks for pointing that out. I will work on it and make it less surprising.

@jasonwbarnett Hello, I have made changes that might suit your needs.

scheduler.at(some_time_in_the_past, discard_past: :fail)
scheduler.in(-3600, discard_past: :fail)

discard_past: true will silently not schedule / discard the job.

It's scheduled for release 3.9.0, not 3.8.3 since it changes the behaviour of rufus-scheduler.

Feedback is welcome.

I reviewed the docs. They are clear and the default to discard past dates is very helpful to avoid surprises. Thanks for the engagement and quick turn around.

@jmettraux is there a scheduled release date for the version with the new functionality?

@jasonwbarnett sorry for the delay, let me release now.

rufus-scheduler 3.9.0 has been released. Thanks!