tods-competition-factory 1.6.10 → 1.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1407,7 +1407,7 @@ function structureSort(a, b, config) {
1407
1407
  const completedStructure = (s) => s?.matchUps.every(
1408
1408
  ({ matchUpStatus }) => completedMatchUpStatuses.includes(matchUpStatus) ? 1 : -1
1409
1409
  );
1410
- return completed && completedStructure(a) - completedStructure(b) || aggregate && protocolSequence(a) - protocolSequence(b) || (a?.stage && orderProtocol[a.stage] || 0) - (b?.stage && orderProtocol[b.stage] || 0) || (getRoundTarget(a) || 0) - (getRoundTarget(b) || 0) || !finish && !aggregate && (b?.positionAssignments?.length || Infinity) - (a?.positionAssignments?.length || Infinity) || (a?.stageSequence || 0) - (b?.stageSequence || 0) || (getMinFinishingPositionRange(a) || 0) - (getMinFinishingPositionRange(b) || 0);
1410
+ return completed && completedStructure(a) - completedStructure(b) || aggregate && protocolSequence(a) - protocolSequence(b) || (a?.stage && orderProtocol[a.stage] || 0) - (b?.stage && orderProtocol[b.stage] || 0) || (getRoundTarget(a) || 0) - (getRoundTarget(b) || 0) || !finish && !aggregate && (b?.positionAssignments?.length ?? Infinity) - (a?.positionAssignments?.length ?? Infinity) || (a?.stageSequence ?? 0) - (b?.stageSequence ?? 0) || (getMinFinishingPositionRange(a) || 0) - (getMinFinishingPositionRange(b) || 0);
1411
1411
  }
1412
1412
  function getMinFinishingPositionRange(structure) {
1413
1413
  return (structure?.matchUps || []).reduce((rangeSum, matchUp) => {
@@ -1517,6 +1517,7 @@ const STRUCTURE_SELECTED_STATUSES = [
1517
1517
 
1518
1518
  function getStageEntries$1({
1519
1519
  provisionalPositioning,
1520
+ placementGroup,
1520
1521
  drawDefinition,
1521
1522
  stageSequence,
1522
1523
  entryStatuses,
@@ -1546,7 +1547,9 @@ function getStageEntries$1({
1546
1547
  if (error) {
1547
1548
  console.log("playoff entries error");
1548
1549
  }
1549
- return playoffEntries?.length ? playoffEntries : entries;
1550
+ return (playoffEntries?.length ? playoffEntries : entries).filter(
1551
+ (entry) => !placementGroup || entry.placementGroup === placementGroup
1552
+ );
1550
1553
  }
1551
1554
  return entries;
1552
1555
  }
@@ -11491,7 +11494,7 @@ function getValidSeedBlocks({
11491
11494
  });
11492
11495
  const { positionAssignments } = structureAssignedDrawPositions({ structure });
11493
11496
  const positionsCount = positionAssignments?.length;
11494
- const seedsCount = seedAssignments?.length || 0;
11497
+ const seedsCount = seedAssignments?.length ?? 0;
11495
11498
  let allDrawPositions = [];
11496
11499
  const roundNumbers = Object.keys(roundMatchUps).map((n) => parseInt(n)).sort((a, b) => a - b);
11497
11500
  const uniqueDrawPositionsByRound = roundNumbers.map((roundNumber) => {
@@ -11753,7 +11756,7 @@ function getNextSeedBlock(params) {
11753
11756
  const seedsWithoutDrawPositions = seedAssignments?.filter(
11754
11757
  (assignment) => !assignment.participantId
11755
11758
  );
11756
- const seedsLeftToAssign = unplacedSeedAssignments?.length || seedsWithoutDrawPositions?.length;
11759
+ const seedsLeftToAssign = unplacedSeedAssignments?.length && unplacedSeedAssignments.length > 0 ? unplacedSeedAssignments.length : seedsWithoutDrawPositions?.length ?? 0;
11757
11760
  const unfilled = seedsLeftToAssign && nextSeedBlock?.drawPositions.filter(
11758
11761
  (drawPosition) => !assignedDrawPositions?.includes(drawPosition)
11759
11762
  ) || [];