tods-competition-factory 1.8.17 → 1.8.18

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.17";
2385
+ return "1.8.18";
2386
2386
  }
2387
2387
 
2388
2388
  function getObjectTieFormat(obj) {
@@ -15940,8 +15940,8 @@ function allTournamentMatchUps(params) {
15940
15940
  if (!participants) {
15941
15941
  ({ participants, participantMap } = hydrateParticipants({
15942
15942
  participantsProfile,
15943
- policyDefinitions,
15944
15943
  useParticipantMap,
15944
+ policyDefinitions,
15945
15945
  tournamentRecord,
15946
15946
  contextProfile,
15947
15947
  inContext
@@ -54623,6 +54623,7 @@ function getParticipantStats({
54623
54623
  withIndividualStats,
54624
54624
  teamParticipantId,
54625
54625
  tournamentRecord,
54626
+ withScaleValues,
54626
54627
  tallyPolicy,
54627
54628
  matchUps
54628
54629
  }) {
@@ -54630,7 +54631,8 @@ function getParticipantStats({
54630
54631
  return { error: MISSING_TOURNAMENT_RECORD };
54631
54632
  if (matchUps && !Array.isArray(matchUps))
54632
54633
  return { error: INVALID_MATCHUP };
54633
- matchUps = matchUps || allTournamentMatchUps({ tournamentRecord }).matchUps;
54634
+ const participantsProfile = withScaleValues ? { withScaleValues } : void 0;
54635
+ matchUps = matchUps || allTournamentMatchUps({ tournamentRecord, participantsProfile }).matchUps;
54634
54636
  if (!matchUps?.length)
54635
54637
  return { error: MISSING_MATCHUPS };
54636
54638
  const teamParticipantIds = [];
@@ -54647,8 +54649,8 @@ function getParticipantStats({
54647
54649
  }
54648
54650
  if (!teamParticipantIds.length)
54649
54651
  teamParticipantIds.push(...teamParticipants.map(extractAttributes("participantId")));
54652
+ const participantDetails = /* @__PURE__ */ new Map();
54650
54653
  const participantStats = /* @__PURE__ */ new Map();
54651
- const participantNameMap = /* @__PURE__ */ new Map();
54652
54654
  const participating = /* @__PURE__ */ new Map();
54653
54655
  const teamMap = /* @__PURE__ */ new Map();
54654
54656
  const initStats = (participantId, participantName = "") => participantStats.get(participantId) || participantStats.set(participantId, {
@@ -54682,11 +54684,13 @@ function getParticipantStats({
54682
54684
  const getSideParticipantIds = (sides) => {
54683
54685
  const sideParticipantIds = [[], []];
54684
54686
  for (const side of sides) {
54685
- if (side.participant?.participantName)
54686
- participantNameMap.set(
54687
- side.participant.participantId,
54688
- side.participant.participantName
54689
- );
54687
+ const participant = side.participant;
54688
+ if (participant?.participantName) {
54689
+ participantDetails.set(participant.participantId, {
54690
+ participantName: participant.participantName,
54691
+ ratings: participant.ratings
54692
+ });
54693
+ }
54690
54694
  }
54691
54695
  const getCompetitorIds = ({ side, individualParticipantIds }) => {
54692
54696
  return side.participantId && (!individualParticipantIds?.length || individualParticipantIds.includes(side.participantId)) && [
@@ -54792,7 +54796,8 @@ function getParticipantStats({
54792
54796
  });
54793
54797
  sideParticipantIds.forEach((ids, index) => {
54794
54798
  for (const id of ids) {
54795
- const stats = initStats(id, participantNameMap.get(id));
54799
+ const participantName = participantDetails.get(id)?.participantName;
54800
+ const stats = initStats(id, participantName);
54796
54801
  if (stats) {
54797
54802
  const teamSumTally = (stat, tally) => tally.forEach((t, i) => stats[stat][i] += t);
54798
54803
  const tiebreaks = index ? [...tiebreaksTally].reverse() : tiebreaksTally;
@@ -60143,10 +60148,10 @@ function getEvents({
60143
60148
  }
60144
60149
  const processFlight = (drawId, participantIds2) => {
60145
60150
  const processParticipant2 = (participant) => {
60146
- if (participant?.ratings?.[eventType]) {
60151
+ if (eventsMap[eventId].draws?.[drawId] && participant?.ratings?.[eventType]) {
60147
60152
  for (const rating of participant?.ratings?.[eventType] ?? []) {
60148
60153
  const scaleName = rating.scaleName;
60149
- if (!eventsMap[eventId].draws[drawId].ratings[scaleName])
60154
+ if (!eventsMap[eventId].draws[drawId]?.ratings[scaleName])
60150
60155
  eventsMap[eventId].draws[drawId].ratings[scaleName] = [];
60151
60156
  const accessor = ratingsParameters[scaleName]?.accessor;
60152
60157
  if (accessor) {