Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 1x 40x 34x 25x 18x 1x 1x 1x 8x 8x 1x 2x 2x 7x 7x 4x 4x 2x 7x 7x 7x 5x 4x 4x 7x 1x 1x 1x 1x 1x 4x 16x 1x 4x 3x 3x 4x 4x 1x 1x 4x 1x | import type { SnapshotIssue } from "./snapshot.ts";
/** Mirrors `ticketStatus` and `dropPlan` in apps/developer-portal/layers/workflows/shared/ticket.ts; change both together. */
export type TicketStatus =
"waiting-on-you" | "ready" | "in-flight" | "blocked" | "done" | "dropped";
export const ticketStatus = (issue: SnapshotIssue): TicketStatus => {
if (issue.state === "closed") return issue.reason === "not_planned" ? "dropped" : "done";
if (issue.branch || issue.pr || issue.activity.length > 0) return "in-flight";
if (issue.blockedBy.some(({ open }) => open)) return "blocked";
return issue.owner ? "waiting-on-you" : "ready";
};
const UNTOUCHED: ReadonlySet<TicketStatus> = new Set(["ready", "blocked", "waiting-on-you"]);
/** The tickets a dropped project closes, and the ones it leaves because work on them started or ended. */
export const dropPlan = (
issues: SnapshotIssue[],
): { close: SnapshotIssue[]; keep: SnapshotIssue[] } => ({
close: issues.filter((issue) => UNTOUCHED.has(ticketStatus(issue))),
keep: issues.filter((issue) => !UNTOUCHED.has(ticketStatus(issue))),
});
/** How many open tickets wait on each one, directly or through a chain of blocked-by links. */
export const unblockCounts = (issues: SnapshotIssue[]): Map<number, number> => {
const waiting = new Map<number, number[]>();
for (const issue of issues) {
Iif (issue.state !== "open") continue;
for (const blocker of issue.blockedBy) {
Eif (blocker.open) {
waiting.set(blocker.number, [...(waiting.get(blocker.number) ?? []), issue.number]);
}
}
}
return new Map(
issues.map((issue) => {
const seen = new Set<number>();
const queue = [...(waiting.get(issue.number) ?? [])];
for (let next = queue.pop(); next !== undefined; next = queue.pop()) {
if (seen.has(next)) continue;
seen.add(next);
queue.push(...(waiting.get(next) ?? []));
}
return [issue.number, seen.size];
}),
);
};
const SECTIONS = [
["waiting-on-you", "Waiting on you"],
["ready", "Ready"],
["in-flight", "In flight"],
["blocked", "Blocked"],
] as const;
/** The open tickets as printable sections, each most-unblocking first; empty sections are left out. */
export const describeQueue = (issues: SnapshotIssue[]): string[] => {
const counts = unblockCounts(issues);
const lines: string[] = [];
for (const [status, heading] of SECTIONS) {
const tickets = issues
.filter((issue) => ticketStatus(issue) === status)
.sort(
(a, b) =>
(counts.get(b.number) ?? 0) - (counts.get(a.number) ?? 0) ||
a.number - b.number,
);
if (tickets.length === 0) continue;
lines.push(`${heading} (${tickets.length})`);
for (const issue of tickets) {
const unblocks = counts.get(issue.number) ?? 0;
const tails = [
issue.caps.length > 0 ? issue.caps.join(", ") : "no cap: label",
unblocks > 0 ? `unblocks ${unblocks}` : "",
status === "blocked"
? `by ${issue.blockedBy
.filter(({ open }) => open)
.map(({ number }) => `#${number}`)
.join(" ")}`
: "",
].filter(Boolean);
lines.push(` #${issue.number} ${issue.title} — ${tails.join(" · ")}`);
}
}
return lines;
};
|