fix(jobs): prevent non-due jobs firing on restart and enrich skip logs with resource links

- Refactor shouldRunNow() to only fire on first run (empty cache) if actually due by cron schedule, preventing spurious executions after cache loss or service restart
- Add enrichSkipLogsWithLinks() method to fetch and populate resource names and links for tasks, backups, and docker cleanup jobs in skip logs
- Update skip logs UI to display resource column with links to related resources, improving navigation and context
- Add fallback display when linked resources are deleted
- Expand tests to cover both restart scenarios: non-due jobs (should not fire) and due jobs (should fire)
This commit is contained in:
Andras Bacsai committed 2026-02-28 18:03:29 +01:00
1 parent 63be5928ab
commit 31555f9e8a
5 files changed
+166 -29

No files matched your search

+13 -2
View File
@@ -341,8 +341,19 @@ class ScheduledJobManager implements ShouldQueue
$lastDispatched = Cache::get($dedupKey);
// Run if: never dispatched before, OR there's been a due time since last dispatch
if ($lastDispatched === null || $previousDue->gt(Carbon::parse($lastDispatched))) {
if ($lastDispatched === null) {
// First run after restart or cache loss: only fire if actually due right now.
// Seed the cache so subsequent runs can use tolerance/catch-up logic.
$isDue = $cron->isDue($executionTime);
if ($isDue) {
Cache::put($dedupKey, $executionTime->toIso8601String(), 86400);
}
return $isDue;
}
// Subsequent runs: fire if there's been a due time since last dispatch
if ($previousDue->gt(Carbon::parse($lastDispatched))) {
Cache::put($dedupKey, $executionTime->toIso8601String(), 86400);
return true;