mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
Show disabled jobs properly in admin health dashboard
- Backup and update check jobs show as "disabled" (not "succeeded") when their respective settings are off - Disabled jobs excluded from "x of y jobs healthy" count, sorted to bottom of list, with schedule/next-run hidden and trigger button disabled - Active jobs sorted by next run time - "Never run" uses amber dot to differentiate from gray "disabled" dot - Extract RefreshButton component and add it to all three health cards Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import { db } from "@/lib/db/client";
|
||||
import { cronRuns, episodes, titles, user } from "@/lib/db/schema";
|
||||
import { listBackups } from "@/lib/services/backup";
|
||||
import { imageCacheEnabled } from "@/lib/services/image-cache";
|
||||
import { getSetting } from "@/lib/services/settings";
|
||||
import { isUpdateCheckEnabled } from "@/lib/services/update-check";
|
||||
|
||||
const DATA_DIR = process.env.DATA_DIR || "./data";
|
||||
const DATABASE_URL =
|
||||
@@ -39,6 +41,7 @@ export interface SystemHealthData {
|
||||
lastStatus: "running" | "success" | "error" | null;
|
||||
lastError: string | null;
|
||||
isCurrentlyRunning: boolean;
|
||||
disabled: boolean;
|
||||
}[];
|
||||
imageCache: {
|
||||
enabled: boolean;
|
||||
@@ -175,15 +178,21 @@ function getJobsHealth(): SystemHealthData["jobs"] {
|
||||
lastDurationMs = latest.finishedAt.getTime() - latest.startedAt.getTime();
|
||||
}
|
||||
|
||||
const disabled =
|
||||
(jobName === "scheduledBackup" &&
|
||||
getSetting("scheduledBackups") !== "true") ||
|
||||
(jobName === "updateCheck" && !isUpdateCheckEnabled());
|
||||
|
||||
return {
|
||||
jobName,
|
||||
cronPattern: schedule?.pattern ?? null,
|
||||
nextRunAt: schedule?.nextRunAt ?? null,
|
||||
cronPattern: disabled ? null : (schedule?.pattern ?? null),
|
||||
nextRunAt: disabled ? null : (schedule?.nextRunAt ?? null),
|
||||
lastRunAt: latest?.startedAt?.toISOString() ?? null,
|
||||
lastDurationMs,
|
||||
lastStatus: (latest?.status as "running" | "success" | "error") ?? null,
|
||||
lastError: latest?.errorMessage ?? null,
|
||||
isCurrentlyRunning,
|
||||
disabled,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user