fix: the resumeOnRestart function to handle correctl the recurring jobs + do not run finished non-recurrent jobs on restart + add unit tests #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
This PR hopes to solve some/all problems that have been flagged under these issues
So, I'm proposing some changes to improve how
resumeOnRestart
works, ensure we’re handling all types of jobs correctly, and fix issues around rescheduling non-recurring jobs that shouldn’t be run again (on restart).What’s Changed?
Improved
resumeOnRestart
lastFinishedAt
but also cover the case in which it isnull
computeNextRunAt
function.Adjusted Job Model nextRunAt default - If a non-recurring jobs is completed (
lastFinishedAt
exists), we should preserve the setnextRunAt
(if it was set explicitly) and we should do not default it tonew Date()
(which triggers a re-run). For the recurrent jobs, we can keep what has been done before (eithernextRunAt
ornew Date()
).Added Test Cases to check as much as we can if resumeOnRestart works properly
Let me know if you spot any edge cases or mistakes I need to fix.