tods-competition-factory 1.8.35 → 1.8.37

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.
@@ -1531,7 +1531,9 @@ type MappedParticipant = {
1531
1531
  eventId: string;
1532
1532
  drawId: string;
1533
1533
  }[];
1534
- scheduleConflicts: ScheduleConflict[];
1534
+ scheduleConflicts: {
1535
+ [key: string]: ScheduleConflict;
1536
+ };
1535
1537
  scheduleItems: any[];
1536
1538
  participant: HydratedParticipant & {
1537
1539
  groupParticipantIds: string[];
@@ -3544,15 +3544,16 @@ function addNationalityCode({
3544
3544
  persons.forEach(annotatePerson);
3545
3545
  }
3546
3546
 
3547
- function addIndividualParticipants({ participantMap }) {
3547
+ function addIndividualParticipants({ participantMap, template }) {
3548
3548
  const participantObjects = Object.values(participantMap);
3549
3549
  for (const participantObject of participantObjects) {
3550
3550
  const participant = participantObject.participant;
3551
3551
  if (participant.individualParticipantIds?.length) {
3552
3552
  participant.individualParticipants = [];
3553
3553
  for (const participantId of participant.individualParticipantIds) {
3554
+ const source = participantMap[participantId].participant;
3554
3555
  participant.individualParticipants.push(
3555
- participantMap[participantId].participant
3556
+ template ? attributeFilter({ template, source }) : source
3556
3557
  );
3557
3558
  }
3558
3559
  }
@@ -3693,8 +3694,10 @@ function getParticipantMap({
3693
3694
  withIOC
3694
3695
  });
3695
3696
  }
3696
- if (withIndividualParticipants)
3697
- addIndividualParticipants({ participantMap });
3697
+ if (withIndividualParticipants) {
3698
+ const template = isObject(withIndividualParticipants) ? withIndividualParticipants : void 0;
3699
+ addIndividualParticipants({ participantMap, template });
3700
+ }
3698
3701
  return { participantMap };
3699
3702
  }
3700
3703
  function signedIn(participant) {
@@ -3754,7 +3757,7 @@ function initializeParticipantId({ participantMap, participantId }) {
3754
3757
  participantMap[participantId] = {
3755
3758
  structureParticipation: {},
3756
3759
  potentialMatchUps: {},
3757
- scheduleConflicts: [],
3760
+ scheduleConflicts: {},
3758
3761
  scheduleItems: [],
3759
3762
  participant: {
3760
3763
  groupParticipantIds: [],
@@ -12356,12 +12359,11 @@ function getParticipantEntries(params) {
12356
12359
  const targetParticipantIds = participantFilters?.participantIds;
12357
12360
  const getRelevantParticipantIds = (participantId) => {
12358
12361
  const relevantParticipantIds = [participantId];
12359
- relevantParticipantIds.push(participantId);
12360
12362
  participantMap[participantId]?.participant.individualParticipantIds?.forEach(
12361
12363
  (individualParticiapntId) => relevantParticipantIds.push(individualParticiapntId)
12362
12364
  );
12363
12365
  return relevantParticipantIds.some(
12364
- (obj) => !targetParticipantIds?.length || targetParticipantIds.includes(obj.relevantParticipantId)
12366
+ (id) => !targetParticipantIds?.length || targetParticipantIds.includes(id)
12365
12367
  ) ? relevantParticipantIds : [];
12366
12368
  };
12367
12369
  const withOpts = {
@@ -12823,15 +12825,16 @@ function getParticipantEntries(params) {
12823
12825
  const itemIsPrior = consideredMinutes >= scheduledMinutes;
12824
12826
  const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : itemIsPrior && timeStringMinutes(consideredItem.scheduledTime) < timeStringMinutes(notBeforeTime);
12825
12827
  if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
12826
- participantAggregator.scheduleConflicts.push({
12828
+ const key = [scheduleItem.matchUpId, consideredItem.matchUpId].sort().join("|");
12829
+ participantAggregator.scheduleConflicts[key] = {
12827
12830
  priorScheduledMatchUpId: scheduleItem.matchUpId,
12828
12831
  matchUpIdWithConflict: consideredItem.matchUpId
12829
- });
12832
+ };
12830
12833
  }
12831
12834
  }
12832
12835
  }
12833
12836
  const pid = participantAggregator.participant.participantId;
12834
- if (participantAggregator.scheduleConflicts.length) {
12837
+ if (Object.keys(participantAggregator.scheduleConflicts).length) {
12835
12838
  participantIdsWithConflicts.push(pid);
12836
12839
  }
12837
12840
  participantMap[pid].scheduleConflicts = participantAggregator.scheduleConflicts;
@@ -12942,7 +12945,7 @@ function getParticipants(params) {
12942
12945
  return definedAttributes(
12943
12946
  {
12944
12947
  ...participant,
12945
- scheduleConflicts: scheduleAnalysis ? scheduleConflicts : void 0,
12948
+ scheduleConflicts: scheduleAnalysis ? Object.values(scheduleConflicts) : void 0,
12946
12949
  draws: withDraws || withRankingProfile ? participantDraws : void 0,
12947
12950
  events: withEvents || withRankingProfile ? Object.values(events) : void 0,
12948
12951
  matchUps: withMatchUps || withRankingProfile ? Object.values(matchUps2) : void 0,
@@ -12969,12 +12972,14 @@ function getParticipants(params) {
12969
12972
  tournamentRecord
12970
12973
  });
12971
12974
  if (withIndividualParticipants) {
12975
+ const template2 = isObject(withIndividualParticipants) ? withIndividualParticipants : void 0;
12972
12976
  for (const participant of filteredParticipants) {
12973
12977
  for (const individualParticipantId of participant.individualParticipantIds ?? []) {
12974
12978
  if (!participant.individualParticipants)
12975
12979
  participant.individualParticipants = [];
12980
+ const source = ppMap.get(individualParticipantId);
12976
12981
  participant.individualParticipants.push(
12977
- ppMap.get(individualParticipantId)
12982
+ template2 ? attributeFilter({ template: template2, source }) : source
12978
12983
  );
12979
12984
  }
12980
12985
  }