brackt/app/routes/admin.sports-seasons.$id.events.$eventId.helpers.ts
Chris Parsons 335d1bf015 feat: fill 0-QP rows for unplaced participants on qualifying event finalize
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 14:28:07 -07:00

22 lines
825 B
TypeScript

/**
* Return participantIds from allParticipantIds that have no entry
* in existingResultParticipantIds. Used to find participants who
* need a 0-QP row after a qualifying event is finalized.
*/
export function findParticipantsWithoutResults(
allParticipantIds: string[],
existingResultParticipantIds: Set<string>
): string[] {
return allParticipantIds.filter((id) => !existingResultParticipantIds.has(id));
}
/**
* Filter incoming batch results to only those whose participantId
* is not already in the set of existing result participantIds.
*/
export function filterNewResults(
incoming: { participantId: string; placement: number }[],
existingParticipantIds: Set<string>
): { participantId: string; placement: number }[] {
return incoming.filter((r) => !existingParticipantIds.has(r.participantId));
}