Updater 3.4 – Lifecycle Hardening #28
@@ -129,9 +129,12 @@ function normalizeRun(run) {
|
||||
}
|
||||
|
||||
function bestRun(runs) {
|
||||
const successful = runs.filter(run => run.state === 'success').sort((a, b) => time(b.updatedAt) - time(a.updatedAt))[0];
|
||||
if (successful) return successful;
|
||||
return [...runs].sort((a, b) => time(b.updatedAt) - time(a.updatedAt))[0];
|
||||
return [...runs].sort((a, b) => {
|
||||
const dateDelta = time(b.updatedAt) - time(a.updatedAt);
|
||||
if (dateDelta) return dateDelta;
|
||||
const rank = { success: 4, pending: 3, failure: 2, cancelled: 1, missing: 0 };
|
||||
return (rank[b.state] || 0) - (rank[a.state] || 0);
|
||||
})[0];
|
||||
}
|
||||
|
||||
export function classifyChecks({ checks = [], workflowRuns = [], requiredChecks = REQUIRED_CHECKS, requiredWorkflows = REQUIRED_WORKFLOWS, elapsedSeconds = 0, gracePeriodSeconds = 90, timedOut = false }) {
|
||||
|
||||
Reference in New Issue
Block a user