mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-09 03:03:18 +08:00
Allow cron_retrigger to immediately fire recurring jobs.
Recurring tasks can start one extra run now without changing the cron schedule; delay remains oneshot-only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
c11221606a
commit
3ce60b200c
5 changed files with 58 additions and 21 deletions
|
|
@ -227,21 +227,23 @@ export function persistHistoryLimit(policy, settingsLimit = 200) {
|
|||
}
|
||||
|
||||
/**
|
||||
* One-shot job whose schedule has been consumed (next cleared) and has a terminal lastStatus.
|
||||
* Used by listeners to decide cron_retrigger vs wait.
|
||||
* Whether cron_retrigger may start a new run now.
|
||||
* - recurring (cron): idle (no pending/running run)
|
||||
* - one-shot (at): consumed (next=n/a) + terminal lastStatus + idle
|
||||
* @param {object|null} job
|
||||
* @param {object[]} [runs]
|
||||
*/
|
||||
export function isRetriggerable(job, runs = []) {
|
||||
if (!job || job.schedule?.kind !== 'at') return false
|
||||
if (!job) return false
|
||||
const list = Array.isArray(runs) ? runs : []
|
||||
if (list.some((run) => run && ACTIVE_RUN_STATUSES.has(run.status))) return false
|
||||
if (job.schedule?.kind === 'cron') return true
|
||||
if (job.schedule?.kind !== 'at') return false
|
||||
if (job.nextRunAt != null) return false
|
||||
const terminal = job.lastStatus === 'succeeded'
|
||||
|| job.lastStatus === 'failed'
|
||||
|| job.lastStatus === 'skipped'
|
||||
if (!terminal) return false
|
||||
const list = Array.isArray(runs) ? runs : []
|
||||
if (list.some((run) => run && ACTIVE_RUN_STATUSES.has(run.status))) return false
|
||||
return true
|
||||
return terminal
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue