From 424f838530b76d76bf7b00d409fbd28c9486d10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Sun, 5 Jan 2025 13:15:38 +0100 Subject: [PATCH] fix(build): fix inconsistent status Fix ARGOS-SERVER-XRE --- apps/backend/src/database/models/Build.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/backend/src/database/models/Build.ts b/apps/backend/src/database/models/Build.ts index 007b49836..51fff261c 100644 --- a/apps/backend/src/database/models/Build.ts +++ b/apps/backend/src/database/models/Build.ts @@ -515,12 +515,23 @@ export class Build extends Model { Build.getStatuses(builds), Build.getReviewStatuses(builds), ]); - const aggregateStatuses = builds.map((build, index) => { - const status = - reviewStatuses[index] || build.conclusion || statuses[index]; - return BuildAggregatedStatusSchema.parse(status); + return builds.map((build, index) => { + if (reviewStatuses[index]) { + return reviewStatuses[index]; + } + if (build.conclusion) { + return build.conclusion; + } + invariant(statuses[index], "status should be fetched"); + // A progress status at this point means that the build has just been + // completed while the status was being fetched. + // So we consider it as progress. + if (statuses[index] === "complete") { + return "progress"; + } + + return statuses[index]; }); - return aggregateStatuses; } /**