tods-competition-factory 1.8.14 → 1.8.15

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.
package/dist/index.mjs CHANGED
@@ -2382,7 +2382,7 @@ const matchUpFormatCode = {
2382
2382
  };
2383
2383
 
2384
2384
  function factoryVersion() {
2385
- return "1.8.14";
2385
+ return "1.8.15";
2386
2386
  }
2387
2387
 
2388
2388
  function getObjectTieFormat(obj) {
@@ -15597,6 +15597,21 @@ function addNationalityCode({
15597
15597
  persons.forEach(annotatePerson);
15598
15598
  }
15599
15599
 
15600
+ function addIndividualParticipants({ participantMap }) {
15601
+ const participantObjects = Object.values(participantMap);
15602
+ for (const participantObject of participantObjects) {
15603
+ const participant = participantObject.participant;
15604
+ if (participant.individualParticipantIds?.length) {
15605
+ participant.individualParticipants = [];
15606
+ for (const participantId of participant.individualParticipantIds) {
15607
+ participant.individualParticipants.push(
15608
+ participantMap[participantId].participant
15609
+ );
15610
+ }
15611
+ }
15612
+ }
15613
+ }
15614
+
15600
15615
  function getTimeItem({
15601
15616
  returnPreviousValues,
15602
15617
  itemSubTypes,
@@ -15778,20 +15793,6 @@ function signedIn(participant) {
15778
15793
  });
15779
15794
  return timeItem?.itemValue === SIGNED_IN;
15780
15795
  }
15781
- function addIndividualParticipants({ participantMap }) {
15782
- const participantObjects = Object.values(participantMap);
15783
- for (const participantObject of participantObjects) {
15784
- const participant = participantObject.participant;
15785
- if (participant.individualParticipantIds?.length) {
15786
- participant.individualParticipants = [];
15787
- for (const participantId of participant.individualParticipantIds) {
15788
- participant.individualParticipants.push(
15789
- participantMap[participantId].participant
15790
- );
15791
- }
15792
- }
15793
- }
15794
- }
15795
15796
  function processIndividualParticipantIds({
15796
15797
  individualParticipantIds,
15797
15798
  participantCopy,
@@ -16070,7 +16071,6 @@ function allEventMatchUps(params) {
16070
16071
  if (!event)
16071
16072
  return { error: MISSING_EVENT };
16072
16073
  const { eventId, eventName, endDate, category, gender, matchUpFormat } = event;
16073
- const eventMatchUps2 = [];
16074
16074
  const additionalContext = {
16075
16075
  ...context,
16076
16076
  ...definedAttributes({
@@ -16114,7 +16114,7 @@ function allEventMatchUps(params) {
16114
16114
  }).scheduleTiming;
16115
16115
  const matchUps = drawDefinitions.flatMap(
16116
16116
  (drawDefinition) => {
16117
- const { matchUps: matchUps2, matchUpsMap } = getAllDrawMatchUps({
16117
+ const { matchUps: matchUps2 } = getAllDrawMatchUps({
16118
16118
  tournamentParticipants: participants,
16119
16119
  tournamentAppliedPolicies,
16120
16120
  scheduleVisibilityFilters,
@@ -16134,12 +16134,10 @@ function allEventMatchUps(params) {
16134
16134
  inContext,
16135
16135
  event
16136
16136
  });
16137
- if (matchUpsMap?.drawMatchUps)
16138
- eventMatchUps2.push(...matchUpsMap.drawMatchUps);
16139
16137
  return matchUps2 ?? [];
16140
16138
  }
16141
16139
  );
16142
- return { matchUps, eventMatchUps: eventMatchUps2 };
16140
+ return { matchUps };
16143
16141
  }
16144
16142
  function tournamentMatchUps(params) {
16145
16143
  if (!params?.tournamentRecord)
@@ -27850,7 +27848,6 @@ function getParticipants$1(params) {
27850
27848
  getMatchUpDependencies({ tournamentRecord });
27851
27849
  }
27852
27850
  let { participantMap } = getParticipantMap({
27853
- withIndividualParticipants,
27854
27851
  convertExtensions,
27855
27852
  tournamentRecord,
27856
27853
  withSignInStatus,
@@ -27889,45 +27886,48 @@ function getParticipants$1(params) {
27889
27886
  const matchUps = entriesResult.matchUps;
27890
27887
  participantMap = entriesResult.participantMap;
27891
27888
  const nextMatchUps = scheduleAnalysis ?? withPotentialMatchUps;
27892
- const processedParticipants = Object.values(participantMap).map(
27893
- ({
27894
- potentialMatchUps,
27895
- scheduleConflicts,
27896
- scheduleItems,
27897
- participant,
27898
- statistics,
27899
- opponents,
27900
- matchUps: matchUps2,
27901
- events,
27902
- draws
27903
- }) => {
27904
- const participantDraws = Object.values(draws);
27905
- const participantOpponents = Object.values(opponents);
27906
- if (withOpponents) {
27907
- participantDraws?.forEach((draw) => {
27908
- draw.opponents = participantOpponents.filter(
27909
- (opponent) => opponent.drawId === draw.drawId
27910
- );
27911
- });
27912
- }
27913
- return definedAttributes(
27914
- {
27915
- ...participant,
27916
- scheduleConflicts: scheduleAnalysis ? scheduleConflicts : void 0,
27917
- draws: withDraws || withRankingProfile ? participantDraws : void 0,
27918
- events: withEvents || withRankingProfile ? Object.values(events) : void 0,
27919
- matchUps: withMatchUps || withRankingProfile ? Object.values(matchUps2) : void 0,
27920
- opponents: withOpponents ? participantOpponents : void 0,
27921
- potentialMatchUps: nextMatchUps ? Object.values(potentialMatchUps) : void 0,
27922
- statistics: withStatistics ? Object.values(statistics) : void 0,
27923
- scheduleItems: withScheduleItems ? scheduleItems : void 0
27924
- },
27925
- false,
27926
- false,
27927
- true
27928
- );
27889
+ const processParticipant = ({
27890
+ potentialMatchUps,
27891
+ scheduleConflicts,
27892
+ scheduleItems,
27893
+ participant,
27894
+ statistics,
27895
+ opponents,
27896
+ matchUps: matchUps2,
27897
+ events,
27898
+ draws
27899
+ }) => {
27900
+ const participantDraws = Object.values(draws);
27901
+ const participantOpponents = Object.values(opponents);
27902
+ if (withOpponents) {
27903
+ participantDraws?.forEach((draw) => {
27904
+ draw.opponents = participantOpponents.filter(
27905
+ (opponent) => opponent.drawId === draw.drawId
27906
+ );
27907
+ });
27929
27908
  }
27930
- );
27909
+ return definedAttributes(
27910
+ {
27911
+ ...participant,
27912
+ scheduleConflicts: scheduleAnalysis ? scheduleConflicts : void 0,
27913
+ draws: withDraws || withRankingProfile ? participantDraws : void 0,
27914
+ events: withEvents || withRankingProfile ? Object.values(events) : void 0,
27915
+ matchUps: withMatchUps || withRankingProfile ? Object.values(matchUps2) : void 0,
27916
+ opponents: withOpponents ? participantOpponents : void 0,
27917
+ potentialMatchUps: nextMatchUps ? Object.values(potentialMatchUps) : void 0,
27918
+ statistics: withStatistics ? Object.values(statistics) : void 0,
27919
+ scheduleItems: withScheduleItems ? scheduleItems : void 0
27920
+ },
27921
+ false,
27922
+ false,
27923
+ true
27924
+ );
27925
+ };
27926
+ const ppMap = /* @__PURE__ */ new Map();
27927
+ for (const participantId of Object.keys(participantMap)) {
27928
+ ppMap.set(participantId, processParticipant(participantMap[participantId]));
27929
+ }
27930
+ const processedParticipants = [...ppMap.values()];
27931
27931
  const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
27932
27932
  const template = participantAttributes?.participant;
27933
27933
  const filteredParticipants = filterParticipants({
@@ -27935,6 +27935,17 @@ function getParticipants$1(params) {
27935
27935
  participantFilters,
27936
27936
  tournamentRecord
27937
27937
  });
27938
+ if (withIndividualParticipants) {
27939
+ for (const participant of filteredParticipants) {
27940
+ for (const individualParticipantId of participant.individualParticipantIds ?? []) {
27941
+ if (!participant.individualParticipants)
27942
+ participant.individualParticipants = [];
27943
+ participant.individualParticipants.push(
27944
+ ppMap.get(individualParticipantId)
27945
+ );
27946
+ }
27947
+ }
27948
+ }
27938
27949
  const participants = template ? filteredParticipants.map(
27939
27950
  (source) => attributeFilter({ source, template })
27940
27951
  ) : filteredParticipants;
@@ -59090,7 +59101,7 @@ function aggregateTieFormats({
59090
59101
  }
59091
59102
  }
59092
59103
  const setTieFormatId = (matchUpId, tieFormatId) => {
59093
- const matchUp = eventMatchUpResult.eventMatchUps?.find(
59104
+ const matchUp = eventMatchUpResult.matchUps?.find(
59094
59105
  (matchUp2) => matchUp2.matchUpId === matchUpId
59095
59106
  );
59096
59107
  if (matchUp) {
@@ -59368,6 +59379,7 @@ function getMaxEntryPosition(params) {
59368
59379
  function getPredictiveAccuracy(params) {
59369
59380
  let { matchUps } = params;
59370
59381
  const {
59382
+ singlesForDoubles,
59371
59383
  tournamentRecord,
59372
59384
  drawDefinition,
59373
59385
  excludeMargin,
@@ -59442,6 +59454,7 @@ function getPredictiveAccuracy(params) {
59442
59454
  const marginCalc = !zoneDoubling || matchUpType === SINGLES$1 ? zoneMargin : (zoneMargin || 0) * 2;
59443
59455
  const zoneData = zoneMargin ? relevantMatchUps.map(({ competitiveProfile, matchUpType: matchUpType2, score, sides }) => {
59444
59456
  const sideValues = getSideValues({
59457
+ singlesForDoubles,
59445
59458
  valueAccessor,
59446
59459
  matchUpType: matchUpType2,
59447
59460
  scaleName,
@@ -59485,6 +59498,7 @@ function getGroupingBands({ zoneData }) {
59485
59498
  return bands;
59486
59499
  }
59487
59500
  function getSideValues({
59501
+ singlesForDoubles,
59488
59502
  exclusionRule,
59489
59503
  valueAccessor,
59490
59504
  matchUpType,
@@ -59505,6 +59519,7 @@ function getSideValues({
59505
59519
  let value = 0;
59506
59520
  for (const participant2 of individualParticipants) {
59507
59521
  const { scaleValue, value: pValue } = getSideValue({
59522
+ singlesForDoubles,
59508
59523
  valueAccessor,
59509
59524
  participant: participant2,
59510
59525
  matchUpType,
@@ -59528,6 +59543,7 @@ function getSideValues({
59528
59543
  };
59529
59544
  } else if (participant) {
59530
59545
  const { scaleValue, value } = getSideValue({
59546
+ singlesForDoubles,
59531
59547
  valueAccessor,
59532
59548
  matchUpType,
59533
59549
  participant,
@@ -59547,11 +59563,18 @@ function getSideValues({
59547
59563
  }
59548
59564
  });
59549
59565
  }
59550
- function getSideValue({ participant, valueAccessor, matchUpType, scaleName }) {
59551
- const ranking = participant?.rankings?.[matchUpType]?.find(
59566
+ function getSideValue({
59567
+ singlesForDoubles,
59568
+ valueAccessor,
59569
+ matchUpType,
59570
+ participant,
59571
+ scaleName
59572
+ }) {
59573
+ const type = singlesForDoubles ? SINGLES$1 : matchUpType;
59574
+ const ranking = participant?.rankings?.[type]?.find(
59552
59575
  (ranking2) => ranking2.scaleName === scaleName
59553
59576
  );
59554
- const rating = participant?.ratings?.[matchUpType]?.find(
59577
+ const rating = participant?.ratings?.[type]?.find(
59555
59578
  (rating2) => rating2.scaleName === scaleName
59556
59579
  );
59557
59580
  const scaleValue = (rating || ranking)?.scaleValue;
@@ -59832,11 +59855,15 @@ function getEvents({
59832
59855
  }
59833
59856
  const ratings = eventsMap[eventId].ratings;
59834
59857
  for (const scaleName of Object.keys(ratings)) {
59858
+ const scaleRating = ratings[scaleName];
59859
+ if (!scaleRating.length)
59860
+ continue;
59861
+ const med = median(scaleRating)?.toFixed(2);
59835
59862
  eventsMap[eventId].ratingsStats[scaleName] = {
59836
- avg: sum(ratings[scaleName]) / ratings[scaleName].length,
59837
- median: median(ratings[scaleName]),
59838
- max: Math.max(...ratings[scaleName]),
59839
- min: Math.min(...ratings[scaleName])
59863
+ avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
59864
+ median: med ? parseFloat(med) : void 0,
59865
+ max: Math.max(...scaleRating),
59866
+ min: Math.min(...scaleRating)
59840
59867
  };
59841
59868
  }
59842
59869
  const processFlight = (drawId, participantIds2) => {
@@ -59899,11 +59926,15 @@ function getEvents({
59899
59926
  for (const drawId of processedDrawIds) {
59900
59927
  const ratings2 = eventsMap[eventId].draws[drawId].ratings;
59901
59928
  for (const scaleName of Object.keys(ratings2)) {
59929
+ const scaleRating = ratings2[scaleName];
59930
+ if (!scaleRating.length)
59931
+ continue;
59932
+ const med = median(scaleRating)?.toFixed(2);
59902
59933
  eventsMap[eventId].draws[drawId].ratingsStats[scaleName] = {
59903
- avg: sum(ratings2[scaleName]) / ratings2[scaleName].length,
59904
- max: Math.max(...ratings2[scaleName]),
59905
- min: Math.min(...ratings2[scaleName]),
59906
- median: median(ratings2[scaleName])
59934
+ avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
59935
+ median: med ? parseFloat(med) : void 0,
59936
+ max: Math.max(...scaleRating),
59937
+ min: Math.min(...scaleRating)
59907
59938
  };
59908
59939
  }
59909
59940
  }