Skip to content

Commit 3b2b2be

Browse files
committed
Filter out the undefined values
1 parent eacc3b1 commit 3b2b2be

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

apps/webapp/app/v3/services/resumeAttempt.server.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,14 @@ export class ResumeAttemptService extends BaseService {
134134

135135
//find the best attempt for each batch item
136136
//it should be the most recent one in a final state
137-
const finalAttempts = dependentBatchItems.map((item) => {
138-
return item.taskRun.attempts
139-
.filter((a) => FINAL_ATTEMPT_STATUSES.includes(a.status))
140-
.sort((a, b) => b.number - a.number)[0];
141-
});
137+
const finalAttempts = dependentBatchItems
138+
.map((item) => {
139+
return item.taskRun.attempts
140+
.filter((a) => FINAL_ATTEMPT_STATUSES.includes(a.status))
141+
.sort((a, b) => b.number - a.number)
142+
.at(0);
143+
})
144+
.filter(Boolean);
142145

143146
completedAttemptIds = finalAttempts.map((a) => a.id);
144147

0 commit comments

Comments
 (0)