commit 1056eea4aa29082e0b7fd7ddb3bc1c3b31a41423
parent 550c70d2b7b84541de119353f30b277377f02237
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 7 Oct 2026 17:46:12 -0400
fetch-windows: /jobs row names who asked, for what, and how many windows
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/common/jobs/jobDetail.test.ts b/common/jobs/jobDetail.test.ts
@@ -0,0 +1,29 @@
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { jobSpecDetail } from "./jobDetail";
+
+// Run with: pnpm --filter yt-dlp-transcript-common exec tsx --test jobs/jobDetail.test.ts
+
+const spec = (kind: string, params: Record<string, unknown>) => ({ kind, slug: "c", params });
+
+test("a single window names who asked and for which clip", () => {
+ assert.equal(
+ jobSpecDetail("fetch-window", spec("fetch-window", { requestedBy: "umtool", manifest: "m", clipId: "c01" })),
+ "umtool · m/c01",
+ );
+});
+
+test("a batch names who asked, for what, and how many windows", () => {
+ assert.equal(
+ jobSpecDetail("fetch-windows", spec("fetch-windows", { requestedBy: "reports", manifest: "demo-site", items: [{}, {}] })),
+ "reports · demo-site · 2 windows",
+ );
+ assert.equal(
+ jobSpecDetail("fetch-windows", spec("fetch-windows", { requestedBy: "umtool", items: [{}] })),
+ "umtool · 1 window",
+ );
+});
+
+test("other kinds add nothing", () => {
+ assert.equal(jobSpecDetail("sync", spec("sync", { requestedBy: "x" })), undefined);
+});
diff --git a/common/jobs/jobDetail.ts b/common/jobs/jobDetail.ts
@@ -13,12 +13,19 @@ export function jobSpecDetail(
kind: string | undefined,
spec: JobSpec | null | undefined,
): string | undefined {
- if (kind !== "fetch-window") return undefined;
+ if (kind !== "fetch-window" && kind !== "fetch-windows") return undefined;
const p = spec?.params ?? {};
const s = (v: unknown): string | null =>
typeof v === "string" && v.trim() !== "" ? v.trim() : null;
const by = s(p.requestedBy);
if (!by) return undefined;
+ if (kind === "fetch-windows") {
+ // A batch: who asked, for what, and how many windows.
+ const n = Array.isArray(p.items) ? p.items.length : 0;
+ return [by, s(p.manifest), `${n} window${n === 1 ? "" : "s"}`]
+ .filter(Boolean)
+ .join(" · ");
+ }
const what = [s(p.manifest), s(p.clipId)].filter(Boolean).join("/");
return what ? `${by} · ${what}` : by;
}