// NEW TRANSCRIPTS ON A LIVE CASE (umtool redesign L4, "What needs you"): a // research case with a pipeline (`/pipeline.json`, common's caseTypes.ts) // that is not done, whose candidate scan last ran at T, and whose scope's // channels have recordings transcribed (or their captions written) since T -- // "14 new transcripts since the last scan". Review group; its action the case's // pipeline page, where Scan candidates runs the scan again. // // "Since the last refresh" is the candidates stage's last finished run // (stages.json): that is the read of the corpus the case's windows come from. // A case never scanned raises nothing -- there is no "since" to count from. // // Pure: lib/inbox/caseCues.ts lists the cases and counts the cues (the // transcript index's per-video mtimes; a fixture with no index, the files). export const CASE_NEW_CUES = "case-new-cues"; /** * The case's `since`: the candidates stage's last done run's end, as ms, or null. * @param {Record | null | undefined} stages readStages() */ export function lastScanOf(stages) { const run = stages?.candidates; if (!run || run.state !== "done") return null; const ms = Date.parse(run.endedAt ?? run.startedAt ?? ""); return Number.isFinite(ms) ? ms : null; } /** * The videos with cues newer than `since`: `{ channel, id, at }[]`, newest first. * @param {Array<{ channel: string, id: string, at: number }>} rows * @param {number} since */ export function newSince(rows, since) { return (Array.isArray(rows) ? rows : []) .filter((r) => r && Number.isFinite(r.at) && r.at > since) .sort((a, b) => b.at - a.at || `${a.channel}/${a.id}`.localeCompare(`${b.channel}/${b.id}`)); } /** * One case's row, or null. * * @param {{ id: string, title: string, since: number, fresh: Array<{ channel: string, id: string, at: number }>, href: string }} o */ export function caseCuesDecision({ id, title, since, fresh, href }) { const n = fresh?.length ?? 0; if (!n) return null; const channels = [...new Set(fresh.map((r) => r.channel))]; const when = new Date(since).toISOString().slice(0, 16).replace("T", " "); return { project: `research/${id}`, projectTitle: title, // The case's piece (lib/research/cases.mjs casePieceId): a case has no lifecycle or mutes yet, so the // Inbox draws no Park or Mute on its card. piece: `c:${id}`, kind: CASE_NEW_CUES, target: id, what: `${n} new transcript${n === 1 ? "" : "s"} since the last scan`, why: `${n} new transcript${n === 1 ? "" : "s"} since the last scan · ${when} UTC · on ${channels.slice(0, 4).join(", ")}${channels.length > 4 ? ` and ${channels.length - 4} more` : ""} — scan the candidates again`, href, severity: "open", at: fresh[0].at, }; }