fix: prioritize follower taskrun visibility
This commit is contained in:
@@ -308,10 +308,41 @@ function compactTimings(timings) {
|
||||
startedAt: stringOrNull(value.startedAt),
|
||||
finishedAt: stringOrNull(value.finishedAt),
|
||||
overBudget: typeof value.overBudget === "boolean" ? value.overBudget : null,
|
||||
stages: arrayRecords(value.stages).slice(0, maxTimingStages).map(compactStageTiming),
|
||||
stages: prioritizedStageTimings(arrayRecords(value.stages)).slice(0, maxTimingStages).map(compactStageTiming),
|
||||
};
|
||||
}
|
||||
|
||||
function prioritizedStageTimings(stages) {
|
||||
const priority = [];
|
||||
const rest = [];
|
||||
for (const stage of stages) {
|
||||
if (isPriorityTaskStage(stage)) priority.push(stage);
|
||||
else rest.push(stage);
|
||||
}
|
||||
const seen = new Set();
|
||||
const out = [];
|
||||
for (const stage of [...priority, ...rest]) {
|
||||
const key = [
|
||||
stringOrNull(stage.stage),
|
||||
stringOrNull(stage.status),
|
||||
stringOrNull(stage.source),
|
||||
stringOrNull(stage.object),
|
||||
].filter((item) => item !== null).join("|");
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
out.push(stage);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function isPriorityTaskStage(stage) {
|
||||
const name = stringOrNull(stage.stage) || "";
|
||||
if (!name.startsWith("task:")) return false;
|
||||
const status = stringOrNull(stage.status) || "";
|
||||
const seconds = numberOrNull(stage.seconds);
|
||||
return status.startsWith("failed") || status === "running" || (seconds !== null && seconds > 60);
|
||||
}
|
||||
|
||||
function compactStageTiming(stage) {
|
||||
return {
|
||||
stage: stringOrNull(stage.stage),
|
||||
|
||||
Reference in New Issue
Block a user