rschmukler/agenda — pull request #81 by nwkeeley (2014-06-28 01:19:45+00:00)
Title: Feature/job repeat at

This feature implements a property called repeatAt().
The reason for repeatAt is that I want the nextRunAt time to be computed based off a set time within the day.

-- job.repeatEvery()
Is quite similar however the nextRunAt time for repeatEvery is calculated based off the interval provided and that interval is applied to the lastRun time.

-- job.schedule()
Is also quite similar in fact the documentation stated: "Specifies the next time at which the job should repeat.".... however job.schedule should really be defined as "Specifies the next time at which the job should run". Calling job.schedule does not set the nextRunAt time.

-- job.repeatAt()
:: The problem ::
I want a schedule a job to run at 10:30pm, and I set the repeatInterval to 24 hours.
The server goes down at 10:20, and comes back online at 10:40pm.
The job will run immediately since it has passed.
The nextRunAt will now be set to 10:40pm.
The will now repeat every 24 hours at 10:40pm.

:: the solution ::
with job.repeatAt matter when the job is ran if there is a repeatAt property it will schedule the nextRunAt time to be the next occurrence of that repeatAt time.