feat(audit): job runs and config changes read in the reader's language (E30 S5)
The audit log showed the server's fixed English lines ("rss_poll: ok — new=5, failed=0",
"log_level = DEBUG", "Background sync paused") to a Hungarian reader. The details are rebuilt from the
row's data on the client: a job run names the job and its result as the inbox does, a config change
names the field and its values (on/off, grouped counts, "default"), a pause/resume adds nothing the
action does not say. A failed run keeps its error text (diagnostic). parseSummary reads enrich's bare
count ("50") back as `enriched`, as the server's `_result_data` names it — the audit and old notices
keep only the one-liner. No backend change; old rows render too.
This commit is contained in:
@@ -55,12 +55,13 @@ describe("an older notice's one-liner", () => {
|
||||
enriched: 0,
|
||||
skipped: "tmdb_api_key not set",
|
||||
});
|
||||
// enrich's bare count, as the server's `_result_data` names it
|
||||
expect(parseSummary("42")).toEqual({ enriched: 42 });
|
||||
});
|
||||
|
||||
it("does not when a phase is nested, or it is no summary at all", () => {
|
||||
expect(parseSummary("recent={'channels_processed': 0}, deep={'videos_added': 1}")).toBeNull();
|
||||
expect(parseSummary("sync paused")).toBeNull();
|
||||
expect(parseSummary("42")).toBeNull();
|
||||
expect(parseSummary(null)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,11 +3,13 @@ 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. */
|
||||
/** A notice from before the result rode along as data — and every audit row — 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, and `enrich`'s bare count ("50") into `{enriched: 50}` as `_result_data` names it; 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;
|
||||
if (/^\d+$/.test(summary)) return { enriched: Number(summary) };
|
||||
const out: JobResult = {};
|
||||
for (const part of summary.split(", ")) {
|
||||
const m = /^(\w+)=(.+)$/.exec(part);
|
||||
|
||||
Reference in New Issue
Block a user