(job: CronJob)
| 183 | } |
| 184 | |
| 185 | function getHealthMeta(job: CronJob): HealthMeta { |
| 186 | const consecutiveErrors = job.consecutiveErrors ?? 0; |
| 187 | |
| 188 | if (!job.lastRun) { |
| 189 | return { |
| 190 | label: "No run history yet", |
| 191 | tone: "neutral", |
| 192 | detailLine: "Results will appear after the first run.", |
| 193 | timestampLabel: "Not executed yet", |
| 194 | }; |
| 195 | } |
| 196 | |
| 197 | if (job.hasIssue || job.lastRunStatus === "error") { |
| 198 | return { |
| 199 | label: "Last run failed", |
| 200 | tone: "error", |
| 201 | detailLine: |
| 202 | consecutiveErrors > 1 |
| 203 | ? `Failed ${consecutiveErrors} times in a row` |
| 204 | : job.lastError?.trim() || "Expand for details.", |
| 205 | timestampLabel: formatFullDate(job.lastRun), |
| 206 | }; |
| 207 | } |
| 208 | |
| 209 | if (job.lastRunStatus === "ok") { |
| 210 | return { |
| 211 | label: "Last run succeeded", |
| 212 | tone: "success", |
| 213 | detailLine: `Duration: ${formatDuration(job.lastDurationMs)}`, |
| 214 | timestampLabel: formatFullDate(job.lastRun), |
| 215 | }; |
| 216 | } |
| 217 | |
| 218 | return { |
| 219 | label: `Last run: ${job.lastRunStatus || "unknown"}`, |
| 220 | tone: "neutral", |
| 221 | detailLine: `Duration: ${formatDuration(job.lastDurationMs)}`, |
| 222 | timestampLabel: formatFullDate(job.lastRun), |
| 223 | }; |
| 224 | } |
| 225 | |
| 226 | function getTimeMeta(job: CronJob): { label: string; value: string; hint: string } { |
| 227 | if (job.nextRun) { |
no test coverage detected