@xeplr/ui-jobs 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/pages/Jobs.jsx +4 -2
- package/src/pages/jobsList.js +20 -3
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ Every call goes through `authFetch`, which prefixes the base URL `@xeplr/ui-acco
|
|
|
115
115
|
- **Jobs table** — name, state (Running, Paused, Manual only, Scheduled), schedule in words (`describeCron`, else "Custom"), next run ("in 3 hours", "due now"), last run, an **on / paused switch**, and **Run now**, **Edit**, **Delete** (confirmed; run history is kept). Search matches name, description and action; sort by name, next run or action.
|
|
116
116
|
- **Run history** — the last-run cell opens that job's newest 50 runs, each with its log.
|
|
117
117
|
- **Recent runs** — the 12 latest runs across all jobs, with duration, trigger and error message.
|
|
118
|
-
- **Live updates** (on by default) — polls `GET /jobs/active` every **2 s** while anything runs and every **15 s** otherwise, so a cron run that starts by itself appears; when the last run finishes, the page reloads once to pick up the final status. Rows show rows read (`1.2K rows`)
|
|
118
|
+
- **Live updates** (on by default) — polls `GET /jobs/active` every **2 s** while anything runs and every **15 s** otherwise, so a cron run that starts by itself appears; when the last run finishes, the page reloads once to pick up the final status. Rows show rows read and when the run last made progress (`1.2K rows · last seen 8 s ago`); a run with no progress for **5 minutes** (`SILENT_MS`) reads "Not responding", because the work beats on every batch it moves. Uncheck to stop polling.
|
|
119
119
|
|
|
120
120
|
State shows **Running** over **Paused**: a pause takes effect at the next pick, and "paused" over a live run invites starting a second one. A job with no schedule has its switch off and disabled — there is nothing for the scheduler to pick.
|
|
121
121
|
|
package/package.json
CHANGED
package/src/pages/Jobs.jsx
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '../api/jobs.js'
|
|
9
9
|
import {
|
|
10
10
|
jobState, STATE_LABELS, describeCron, nextRunLabel, durationLabel,
|
|
11
|
-
latestByJob, prepareJobs, progressLabel, progressStale
|
|
11
|
+
latestByJob, prepareJobs, progressLabel, progressStale, lastSeenLabel
|
|
12
12
|
} from './jobsList.js'
|
|
13
13
|
import CronScheduleField from '../components/CronScheduleField.jsx'
|
|
14
14
|
import './Jobs.css'
|
|
@@ -1069,10 +1069,12 @@ export default function Jobs({ breadcrumb: Breadcrumb, uploadLink, connectLink }
|
|
|
1069
1069
|
<span
|
|
1070
1070
|
className={progressStale(liveRun) ? 'jb-progress jb-progress--stale' : 'jb-progress'}
|
|
1071
1071
|
title={progressStale(liveRun)
|
|
1072
|
-
? 'No
|
|
1072
|
+
? 'No progress for five minutes: the worker doing this has most likely died.'
|
|
1073
1073
|
: `Rows read so far. Last update ${new Date(liveRun.progress.at).toLocaleTimeString()}.`}
|
|
1074
1074
|
>
|
|
1075
|
+
{progressStale(liveRun) ? 'Not responding · ' : ''}
|
|
1075
1076
|
{progressLabel(liveRun)}
|
|
1077
|
+
{lastSeenLabel(liveRun) ? ` · ${lastSeenLabel(liveRun)}` : ''}
|
|
1076
1078
|
</span>
|
|
1077
1079
|
)}
|
|
1078
1080
|
</td>
|
package/src/pages/jobsList.js
CHANGED
|
@@ -186,11 +186,28 @@ export function formatCount(n) {
|
|
|
186
186
|
* what lets a row say "no update for 9m" instead of showing a stale count as
|
|
187
187
|
* though it were current.
|
|
188
188
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
189
|
+
* Five minutes (SILENT_MS): the work beats on every batch it moves, so a
|
|
190
|
+
* run silent that long is not running, whatever its status says.
|
|
191
191
|
*/
|
|
192
|
-
export function progressStale(occurrence, now = Date.now(), toleranceMs =
|
|
192
|
+
export function progressStale(occurrence, now = Date.now(), toleranceMs = SILENT_MS) {
|
|
193
193
|
const at = occurrence && occurrence.progress && occurrence.progress.at
|
|
194
194
|
if (!at) return false
|
|
195
195
|
return now - new Date(at).getTime() > toleranceMs
|
|
196
196
|
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* How long a run may go without progress before it is treated as not
|
|
200
|
+
* running: five minutes, the same rule the host applies to the action runs
|
|
201
|
+
* it records (a job's progress IS its action's progress).
|
|
202
|
+
*/
|
|
203
|
+
export const SILENT_MS = 5 * 60 * 1000
|
|
204
|
+
|
|
205
|
+
/** "last seen 8 s ago" / "last seen 7 min ago" from progress.at, or null. */
|
|
206
|
+
export function lastSeenLabel(occurrence, now = Date.now()) {
|
|
207
|
+
const at = occurrence && occurrence.progress && occurrence.progress.at
|
|
208
|
+
if (!at) return null
|
|
209
|
+
const secs = Math.max(0, Math.round((now - new Date(at).getTime()) / 1000))
|
|
210
|
+
if (secs < 60) return `last seen ${secs} s ago`
|
|
211
|
+
if (secs < 3600) return `last seen ${Math.floor(secs / 60)} min ago`
|
|
212
|
+
return `last seen ${Math.floor(secs / 3600)} h ago`
|
|
213
|
+
}
|