mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
storing last run in database
This commit is contained in:
@@ -104,7 +104,6 @@ export function initJobExecutionService({ providers, settings, intervalMs }) {
|
||||
logger.debug('Working hours set. Skipping as outside of working hours.');
|
||||
return;
|
||||
}
|
||||
settings.lastRun = now;
|
||||
const jobs = jobStorage.getJobs().filter((job) => {
|
||||
if (!context) return true; // startup/cron → all
|
||||
if (context.isAdmin) return true; // admin → all
|
||||
@@ -150,6 +149,13 @@ export function initJobExecutionService({ providers, settings, intervalMs }) {
|
||||
}
|
||||
const acquired = markRunning(job.id);
|
||||
if (!acquired) return;
|
||||
// Persist the trigger time so the dashboard "last search" KPI can be
|
||||
// derived per accessible user without an in-memory cache.
|
||||
try {
|
||||
jobStorage.updateJobLastRunAt(job.id, Date.now());
|
||||
} catch (err) {
|
||||
logger.warn('Failed to persist last_run_at for job', job.id, err);
|
||||
}
|
||||
// notify listeners (SSE) that the job started
|
||||
try {
|
||||
bus.emit('jobs:status', { jobId: job.id, running: true });
|
||||
|
||||
Reference in New Issue
Block a user