feat(inbox): a run notice from before the result rode along reads its one-liner back into one (E30 S2)
This commit is contained in:
@@ -3,6 +3,21 @@ import type { JobResult } from "./api";
|
||||
import { formatNumber } from "./format";
|
||||
import { vocabKey } from "./vocab";
|
||||
|
||||
/** A notice from before the result rode along as data holds only the server's one-liner: `_summarize`'s
|
||||
* "new=3, failed=0" (backend/app/scheduler.py). A flat one reads back into a result; a nested phase
|
||||
* (a Python dict repr) or anything else does not, and stays as it was. */
|
||||
export function parseSummary(summary: string | null | undefined): JobResult | null {
|
||||
if (!summary || /[{}[\]]/.test(summary)) return null;
|
||||
const out: JobResult = {};
|
||||
for (const part of summary.split(", ")) {
|
||||
const m = /^(\w+)=(.+)$/.exec(part);
|
||||
if (!m) return null;
|
||||
const [, key, raw] = m;
|
||||
out[key!] = /^-?\d+$/.test(raw!) ? Number(raw) : raw!;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** A scheduler job's result in the reader's language (E30): "új videó: 3 · sikertelen: 0". The server
|
||||
* stored "new=3, failed=0" — English keys, a Python dict repr for a nested phase. A count's key is
|
||||
* named from `scheduler.result`, a `skipped` / `reason` word from `scheduler.skip`; an unnamed key or
|
||||
|
||||
Reference in New Issue
Block a user