mirror of
https://github.com/RightNow-AI/openfang.git
synced 2026-07-30 06:32:17 +00:00
Fix failed manual run pushing next_run and premature last_run in UI
- record_failure() now only recomputes next_run when the job is already overdue (next_run <= now), preserving the scheduled fire time when a manual run fails before the job's natural next_run - Remove premature job.last_run update in scheduler.js — the job runs asynchronously so last_run should only reflect the server-side completion timestamp on the next data refresh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -204,7 +204,9 @@ function schedulerPage() {
|
||||
var result = await OpenFangAPI.post('/api/cron/jobs/' + job.id + '/run', {});
|
||||
if (result.status === 'triggered' || result.status === 'completed') {
|
||||
OpenFangToast.success('Job "' + (job.name || 'job') + '" triggered');
|
||||
job.last_run = new Date().toISOString();
|
||||
// Don't update job.last_run here — the job runs asynchronously in the
|
||||
// background. The real last_run is set by the server on completion and
|
||||
// will appear on the next data refresh.
|
||||
} else {
|
||||
OpenFangToast.error('Run failed: ' + (result.error || 'Unknown error'));
|
||||
}
|
||||
|
||||
@@ -387,7 +387,13 @@ impl CronScheduler {
|
||||
);
|
||||
meta.job.enabled = false;
|
||||
} else {
|
||||
meta.job.next_run = Some(compute_next_run_after(&meta.job.schedule, Utc::now()));
|
||||
// Only recompute next_run if the job was already overdue. This
|
||||
// preserves the scheduled fire time when a manual (on-demand) run
|
||||
// fails before the job's natural next_run.
|
||||
let now = Utc::now();
|
||||
if meta.job.next_run.map(|t| t <= now).unwrap_or(true) {
|
||||
meta.job.next_run = Some(compute_next_run_after(&meta.job.schedule, now));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user