feat(workflows): pick a lane in the pipeline pass-rate panel
The panel aggregated every lane at once, which answers "does this stage get proved across the project" but never "does THIS lane prove it". A lane picker now narrows the same aggregation through ?lane=<id> on GET /api/lanes/pipeline-stats, counting that lane plus its own archived features — dropping the features would hide most of a lane's history the moment it starts its next one. The response carries a `lanes` array that the filter never narrows: it populates the picker, so it has to keep offering every other lane even while the counts show one. For the same reason the picker renders above the empty branch rather than inside the populated one — narrowing to a lane that has recorded nothing would otherwise be a one-way trip, with no control left to select anything else. A lane filter that is not a positive integer is rejected with 400 EBADLANE rather than silently aggregating everything.
This commit is contained in:
+26
-6
@@ -146,12 +146,31 @@ router.get("/pipelines", (_req, res) => res.json({ pipelines: listPipelines() })
|
||||
* separately rather than folded into the pass rate, because "claimed" and
|
||||
* "proved" are not the same fact — the same distinction the pipeline map draws
|
||||
* between `done` and `passed-no-evidence`. Also registered before "/:id".
|
||||
*
|
||||
* `?lane=<id>` narrows the same aggregation to one lane and its own archived
|
||||
* features. The returned `lanes` list is never narrowed — it populates the
|
||||
* picker, so it has to keep offering the way back to every other lane.
|
||||
*/
|
||||
router.get("/pipeline-stats", (_req, res) => {
|
||||
const rows = [
|
||||
...db.prepare("SELECT pipeline, stages FROM lanes").all(),
|
||||
...db.prepare("SELECT pipeline, stages FROM lane_features").all(),
|
||||
];
|
||||
router.get("/pipeline-stats", (req, res) => {
|
||||
const laneFilter = req.query.lane;
|
||||
let laneId = null;
|
||||
if (laneFilter !== undefined && laneFilter !== "" && laneFilter !== "all") {
|
||||
laneId = Number(laneFilter);
|
||||
if (!Number.isInteger(laneId) || laneId < 1) {
|
||||
return res.status(400).json({ error: { code: "EBADLANE", message: "lane must be an id" } });
|
||||
}
|
||||
}
|
||||
|
||||
const rows =
|
||||
laneId === null
|
||||
? [
|
||||
...db.prepare("SELECT pipeline, stages FROM lanes").all(),
|
||||
...db.prepare("SELECT pipeline, stages FROM lane_features").all(),
|
||||
]
|
||||
: [
|
||||
...db.prepare("SELECT pipeline, stages FROM lanes WHERE id = ?").all(laneId),
|
||||
...db.prepare("SELECT pipeline, stages FROM lane_features WHERE lane_id = ?").all(laneId),
|
||||
];
|
||||
|
||||
const acc = new Map();
|
||||
for (const row of rows) {
|
||||
@@ -198,7 +217,8 @@ router.get("/pipeline-stats", (_req, res) => {
|
||||
// Busiest pipeline first: the one with the most recorded runs is the one the
|
||||
// reader most likely came to look at.
|
||||
const pipelines = [...acc.values()].sort((a, b) => b.runs - a.runs);
|
||||
res.json({ pipelines });
|
||||
const lanes = db.prepare("SELECT id, title, cwd FROM lanes ORDER BY id").all();
|
||||
res.json({ pipelines, lanes });
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user