fix(audit): fold a job's successful runs whatever ran between them
The owner read a fold that broke at every other job as the same row five times. A job's successful runs now fold into one row at the newest run's place across other jobs and admin actions; only that job's own failed or skipped run breaks the fold (it stays its own row, and older successes start a new fold below it).
This commit is contained in:
+1
-1
@@ -695,7 +695,7 @@ of a full-width panel and nothing on the right.
|
|||||||
| 2026-10-01 | E31 Statistics overview | Number tiles, and the per-operation counts as horizontal bars | Three narrow cards; a 30-day chart | The label sits by its value; what spends the quota is seen at a glance |
|
| 2026-10-01 | E31 Statistics overview | Number tiles, and the per-operation counts as horizontal bars | Three narrow cards; a 30-day chart | The label sits by its value; what spends the quota is seen at a glance |
|
||||||
| 2026-10-01 | E31 Channel page header | The full banner, folding to one row once the grid scrolls | Always compact; no banner | The header is fixed and took 40% of a 685px window; the channel keeps its face at first sight |
|
| 2026-10-01 | E31 Channel page header | The full banner, folding to one row once the grid scrolls | Always compact; no banner | The header is fixed and took 40% of a 685px window; the channel keeps its face at first sight |
|
||||||
| 2026-10-01 | E31 Channel page watch state | A fresh channel page shows the unwatched videos; a picked state is remembered | Show all, forgotten on reload | The owner: open a channel to see what is new; a choice made there should stick |
|
| 2026-10-01 | E31 Channel page watch state | A fresh channel page shows the unwatched videos; a picked state is remembered | Show all, forgotten on reload | The owner: open a channel to see what is new; a choice made there should stick |
|
||||||
| 2026-10-01 | E31 Audit log runs | Back-to-back successful runs of one job fold into one row that opens; a failure is never folded and reads in the danger colour | A filter defaulting to admin actions; both | Nothing hidden, the noise collapsed, the failure seen |
|
| 2026-10-01 | E31 Audit log runs | A job's successful runs fold into one row that opens, whatever ran between; only that job's failure (never folded, danger colour) breaks it | A filter defaulting to admin actions; both | Nothing hidden, the noise collapsed, the failure seen |
|
||||||
| 2026-10-01 | E31 Users row | Role and state as badges, the actions in the row's one menu | An inline role toggle; icon-only buttons | Action placement: the row shows state, rare and destructive actions live in the menu |
|
| 2026-10-01 | E31 Users row | Role and state as badges, the actions in the row's one menu | An inline role toggle; icon-only buttons | Action placement: the row shows state, rare and destructive actions live in the menu |
|
||||||
| 2026-10-01 | E31 YouTube player | Video beside an info panel at 1280px and wider (the video as large as the height allows); stacked below | Today's stack with a one-line bar; full-window like Plex | The owner's eyesight: about 1460px of video on 1080p instead of 1008, the actions still visible |
|
| 2026-10-01 | E31 YouTube player | Video beside an info panel at 1280px and wider (the video as large as the height allows); stacked below | Today's stack with a one-line bar; full-window like Plex | The owner's eyesight: about 1460px of video on 1080p instead of 1008, the actions still visible |
|
||||||
| 2026-10-01 | E31 Plex info and show pages | A second column for the facts, keywords and crew, as the person page; a collection's hero sized to its content | Full-width text; a larger poster and fanart | The right ~40% was empty; one composition for every media page |
|
| 2026-10-01 | E31 Plex info and show pages | A second column for the facts, keywords and crew, as the person page; a collection's hero sized to its content | Full-width text; a larger poster and fanart | The right ~40% was empty; one composition for every media page |
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// E31: the audit log's first screen was one job's "done" ten times over. Back-to-back successful runs
|
// E31: the audit log's first screen was one job's "done" ten times over. A job's successful runs fold
|
||||||
// of one job fold into one row; a failure, a skip, another job or an admin's own action breaks the run.
|
// into one row whatever ran between them (the owner: a fold broken by every other job read as the same
|
||||||
|
// row five times); only that job's own failure or skip breaks it.
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import type { AuditRow } from "./api";
|
import type { AuditRow } from "./api";
|
||||||
import { foldJobRuns } from "./auditGroups";
|
import { foldJobRuns } from "./auditGroups";
|
||||||
@@ -22,7 +23,7 @@ const shape = (rows: ReturnType<typeof foldJobRuns>) =>
|
|||||||
rows.map((r) => `${r.target_id}:${String(r.after?.status)}×${r.runs?.length ?? 1}`);
|
rows.map((r) => `${r.target_id}:${String(r.after?.status)}×${r.runs?.length ?? 1}`);
|
||||||
|
|
||||||
describe("folding the job runs", () => {
|
describe("folding the job runs", () => {
|
||||||
it("folds back-to-back successful runs of one job, newest first", () => {
|
it("folds a job's successful runs into one row, newest first", () => {
|
||||||
const rows = [run("enrich"), run("enrich"), run("enrich"), run("people")];
|
const rows = [run("enrich"), run("enrich"), run("enrich"), run("people")];
|
||||||
const out = foldJobRuns(rows);
|
const out = foldJobRuns(rows);
|
||||||
expect(shape(out)).toEqual(["enrich:ok×3", "people:ok×1"]);
|
expect(shape(out)).toEqual(["enrich:ok×3", "people:ok×1"]);
|
||||||
@@ -44,11 +45,22 @@ describe("folding the job runs", () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps an admin's own action between two runs, and the runs apart", () => {
|
it("folds across other jobs and an admin's own action, each at its own place", () => {
|
||||||
expect(shape(foldJobRuns([run("enrich"), admin(), run("enrich")]))).toEqual([
|
const rows = [run("enrich"), run("plex"), run("enrich"), admin(), run("shorts"), run("enrich")];
|
||||||
"enrich:ok×1",
|
rows.push(run("plex"));
|
||||||
"x:ok×1",
|
const out = foldJobRuns(rows);
|
||||||
|
expect(shape(out)).toEqual(["enrich:ok×3", "plex:ok×2", "x:ok×1", "shorts:ok×1"]);
|
||||||
|
expect(out[0]!.runs!.map((r) => r.id)).toEqual([rows[0]!.id, rows[2]!.id, rows[5]!.id]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("starts a new fold below the job's own failure, which another job's does not", () => {
|
||||||
|
const rows = [run("enrich"), run("enrich", "error"), run("enrich"), run("rss", "error")];
|
||||||
|
rows.push(run("enrich"));
|
||||||
|
expect(shape(foldJobRuns(rows))).toEqual([
|
||||||
"enrich:ok×1",
|
"enrich:ok×1",
|
||||||
|
"enrich:error×1",
|
||||||
|
"enrich:ok×2",
|
||||||
|
"rss:error×1",
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,31 +2,47 @@ import type { AuditRow } from "./api";
|
|||||||
|
|
||||||
// The audit log's scheduler noise, folded (E31, the owner's pick): the background jobs write a row per
|
// The audit log's scheduler noise, folded (E31, the owner's pick): the background jobs write a row per
|
||||||
// run that changed something, so an hour of "enrichment done" filled the first screen and pushed the
|
// run that changed something, so an hour of "enrichment done" filled the first screen and pushed the
|
||||||
// admins' own actions down. Back-to-back SUCCESSFUL runs of the same job become one row that names how
|
// admins' own actions down. A job's SUCCESSFUL runs become one row that names how many there were and
|
||||||
// many there were and opens to each; a failed or skipped run is never folded — it stays a row of its
|
// opens to each — whatever ran between them (another job, an admin's action): the owner read a fold
|
||||||
// own, where it is seen. Rows arrive newest first; the group stands at its newest run's place.
|
// that broke at every other job as the same row five times. Only that job's own failed or skipped run
|
||||||
|
// breaks it: that row stays on its own, at its moment, where it is seen, and the job's older successes
|
||||||
|
// start a new fold below it. Rows arrive newest first; a fold stands at its newest run's place.
|
||||||
|
|
||||||
/** An audit row as the table lists it: a lone row, or the newest of a run of folded ones (`runs`, the
|
/** An audit row as the table lists it: a lone row, or the newest of a job's folded runs (`runs`, the
|
||||||
* whole run newest first, the row itself included). */
|
* whole fold newest first, the row itself included). */
|
||||||
export type AuditListRow = AuditRow & { runs?: AuditRow[] };
|
export type AuditListRow = AuditRow & { runs?: AuditRow[] };
|
||||||
|
|
||||||
/** The job a row is a successful run of, or null for any other row. */
|
/** The job a row is a run of, or null for any other row. */
|
||||||
function okRunOf(row: AuditRow): string | null {
|
function jobOf(row: AuditRow): string | null {
|
||||||
if (row.action !== "job_run" || row.target_type !== "job" || !row.target_id) return null;
|
return row.action === "job_run" && row.target_type === "job" && row.target_id
|
||||||
return row.after?.status === "ok" ? row.target_id : null;
|
? row.target_id
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function foldJobRuns(rows: readonly AuditRow[]): AuditListRow[] {
|
export function foldJobRuns(rows: readonly AuditRow[]): AuditListRow[] {
|
||||||
const out: AuditListRow[] = [];
|
const out: AuditListRow[] = [];
|
||||||
let head: AuditListRow | null = null;
|
// Each job's open fold: the row its next older success joins.
|
||||||
|
const open = new Map<string, AuditListRow>();
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const job = okRunOf(row);
|
const job = jobOf(row);
|
||||||
if (job !== null && head !== null && okRunOf(head) === job) {
|
if (job === null) {
|
||||||
|
out.push(row);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (row.after?.status !== "ok") {
|
||||||
|
// A failure or a skip stands alone and closes the job's fold.
|
||||||
|
open.delete(job);
|
||||||
|
out.push(row);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const head = open.get(job);
|
||||||
|
if (head) {
|
||||||
head.runs = [...(head.runs ?? [head]), row];
|
head.runs = [...(head.runs ?? [head]), row];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
head = { ...row };
|
const fresh: AuditListRow = { ...row };
|
||||||
out.push(head);
|
open.set(job, fresh);
|
||||||
|
out.push(fresh);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user