Remove repeatable job based on processing result
Created by: Maximization
I have a cron job that runs every x seconds. After the job is done, based on the result, I'd like the previous processing run to be the last one and remove the job from the queue. Also ideally I'd like to change the cron value based on some result output. But if I can remove the repeatable job then I could accomplish this by removing the old repeatable job and adding a new one with new cron parameters.
I've tried using job.remove() and job.discard() during the 'completed' event but that wouldn't work since it would remove the current job which has just been completed and not the next repeatable job placed in the queue when the current job was moved to active.
I've also tried changing the repeat options directly through job.opts.repeat = .. but this wouldn't work for the same reason.
What's the recommended approach here? I'd be happy to provide some code if that would help paint a clearer picture.