show last-run status/time/message for finished jobs in the admin panel
The Jobs panel only surfaced live progress; once a job finished you couldn't see when it ran, whether it succeeded, or its message (e.g. a regime/collector error). Add a "Last run <ago> · <status> — <message>" line per job, colored by status, from the runtime_* fields the backend already returns. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,22 @@ function formatNextRun(iso: string | null): string {
|
|||||||
return `in ${hrs}h`;
|
return `in ${hrs}h`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatAgo(iso: string | null | undefined): string {
|
||||||
|
if (!iso) return '';
|
||||||
|
const mins = Math.floor((Date.now() - new Date(iso).getTime()) / 60_000);
|
||||||
|
if (mins < 1) return 'just now';
|
||||||
|
if (mins < 60) return `${mins}m ago`;
|
||||||
|
const hrs = Math.floor(mins / 60);
|
||||||
|
if (hrs < 24) return `${hrs}h ago`;
|
||||||
|
return `${Math.floor(hrs / 24)}d ago`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function lastRunColor(status: string | null | undefined): string {
|
||||||
|
if (status === 'error') return 'text-red-300';
|
||||||
|
if (status === 'rate_limited') return 'text-amber-300';
|
||||||
|
return 'text-gray-500';
|
||||||
|
}
|
||||||
|
|
||||||
export function JobControls() {
|
export function JobControls() {
|
||||||
const { data: jobs, isLoading } = useJobs();
|
const { data: jobs, isLoading } = useJobs();
|
||||||
const toggleJob = useToggleJob();
|
const toggleJob = useToggleJob();
|
||||||
@@ -139,6 +155,13 @@ export function JobControls() {
|
|||||||
<span className="text-[11px] text-red-400">Not registered</span>
|
<span className="text-[11px] text-red-400">Not registered</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{!job.running && job.runtime_finished_at && (
|
||||||
|
<div className={`mt-1 text-[11px] ${lastRunColor(job.runtime_status)}`}>
|
||||||
|
Last run {formatAgo(job.runtime_finished_at)}
|
||||||
|
{job.runtime_status ? ` · ${job.runtime_status}` : ''}
|
||||||
|
{job.runtime_message ? ` — ${job.runtime_message}` : ''}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{job.running && (
|
{job.running && (
|
||||||
<div className="mt-2 space-y-1.5">
|
<div className="mt-2 space-y-1.5">
|
||||||
<div className="flex items-center justify-between text-[11px] text-gray-400">
|
<div className="flex items-center justify-between text-[11px] text-gray-400">
|
||||||
|
|||||||
Reference in New Issue
Block a user