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.
@@ -2905,7 +2905,7 @@ var matchUpFormatCode = {
2905
2905
  };
2906
2906
 
2907
2907
  function factoryVersion() {
2908
- return '1.8.14';
2908
+ return '1.8.15';
2909
2909
  }
2910
2910
 
2911
2911
  function getObjectTieFormat(obj) {
@@ -17237,6 +17237,42 @@ function addNationalityCode(_a) {
17237
17237
  persons.forEach(annotatePerson);
17238
17238
  }
17239
17239
 
17240
+ function addIndividualParticipants(_a) {
17241
+ var e_1, _b, e_2, _c;
17242
+ var _d;
17243
+ var participantMap = _a.participantMap;
17244
+ var participantObjects = Object.values(participantMap);
17245
+ try {
17246
+ for (var participantObjects_1 = __values(participantObjects), participantObjects_1_1 = participantObjects_1.next(); !participantObjects_1_1.done; participantObjects_1_1 = participantObjects_1.next()) {
17247
+ var participantObject = participantObjects_1_1.value;
17248
+ var participant = participantObject.participant;
17249
+ if ((_d = participant.individualParticipantIds) === null || _d === void 0 ? void 0 : _d.length) {
17250
+ participant.individualParticipants = [];
17251
+ try {
17252
+ for (var _e = (e_2 = void 0, __values(participant.individualParticipantIds)), _f = _e.next(); !_f.done; _f = _e.next()) {
17253
+ var participantId = _f.value;
17254
+ participant.individualParticipants.push(participantMap[participantId].participant);
17255
+ }
17256
+ }
17257
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
17258
+ finally {
17259
+ try {
17260
+ if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
17261
+ }
17262
+ finally { if (e_2) throw e_2.error; }
17263
+ }
17264
+ }
17265
+ }
17266
+ }
17267
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
17268
+ finally {
17269
+ try {
17270
+ if (participantObjects_1_1 && !participantObjects_1_1.done && (_b = participantObjects_1.return)) _b.call(participantObjects_1);
17271
+ }
17272
+ finally { if (e_1) throw e_1.error; }
17273
+ }
17274
+ }
17275
+
17240
17276
  function getTimeItem(_a) {
17241
17277
  var returnPreviousValues = _a.returnPreviousValues, itemSubTypes = _a.itemSubTypes, itemType = _a.itemType, element = _a.element;
17242
17278
  if (!element)
@@ -17413,43 +17449,8 @@ function signedIn(participant) {
17413
17449
  }).timeItem;
17414
17450
  return (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === SIGNED_IN;
17415
17451
  }
17416
- function addIndividualParticipants(_a) {
17417
- var e_3, _b, e_4, _c;
17418
- var _d;
17419
- var participantMap = _a.participantMap;
17420
- var participantObjects = Object.values(participantMap);
17421
- try {
17422
- for (var participantObjects_1 = __values(participantObjects), participantObjects_1_1 = participantObjects_1.next(); !participantObjects_1_1.done; participantObjects_1_1 = participantObjects_1.next()) {
17423
- var participantObject = participantObjects_1_1.value;
17424
- var participant = participantObject.participant;
17425
- if ((_d = participant.individualParticipantIds) === null || _d === void 0 ? void 0 : _d.length) {
17426
- participant.individualParticipants = [];
17427
- try {
17428
- for (var _e = (e_4 = void 0, __values(participant.individualParticipantIds)), _f = _e.next(); !_f.done; _f = _e.next()) {
17429
- var participantId = _f.value;
17430
- participant.individualParticipants.push(participantMap[participantId].participant);
17431
- }
17432
- }
17433
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
17434
- finally {
17435
- try {
17436
- if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
17437
- }
17438
- finally { if (e_4) throw e_4.error; }
17439
- }
17440
- }
17441
- }
17442
- }
17443
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
17444
- finally {
17445
- try {
17446
- if (participantObjects_1_1 && !participantObjects_1_1.done && (_b = participantObjects_1.return)) _b.call(participantObjects_1);
17447
- }
17448
- finally { if (e_3) throw e_3.error; }
17449
- }
17450
- }
17451
17452
  function processIndividualParticipantIds(_a) {
17452
- var e_5, _b;
17453
+ var e_3, _b;
17453
17454
  var individualParticipantIds = _a.individualParticipantIds, participantCopy = _a.participantCopy, participantMap = _a.participantMap, participantType = _a.participantType, participantId = _a.participantId;
17454
17455
  var _loop_1 = function (individualParticipantId) {
17455
17456
  var individualParticipant = participantMap[individualParticipantId].participant;
@@ -17479,12 +17480,12 @@ function processIndividualParticipantIds(_a) {
17479
17480
  _loop_1(individualParticipantId);
17480
17481
  }
17481
17482
  }
17482
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
17483
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
17483
17484
  finally {
17484
17485
  try {
17485
17486
  if (individualParticipantIds_1_1 && !individualParticipantIds_1_1.done && (_b = individualParticipantIds_1.return)) _b.call(individualParticipantIds_1);
17486
17487
  }
17487
- finally { if (e_5) throw e_5.error; }
17488
+ finally { if (e_3) throw e_3.error; }
17488
17489
  }
17489
17490
  }
17490
17491
  function initializeParticipantId(_a) {
@@ -17674,7 +17675,6 @@ function allEventMatchUps(params) {
17674
17675
  if (!event)
17675
17676
  return { error: MISSING_EVENT };
17676
17677
  var eventId = event.eventId, eventName = event.eventName, endDate = event.endDate, category = event.category, gender = event.gender, matchUpFormat = event.matchUpFormat;
17677
- var eventMatchUps = [];
17678
17678
  var additionalContext = __assign(__assign({}, context), definedAttributes({
17679
17679
  indoorOutDoor: (_a = event.indoorOutdoor) !== null && _a !== void 0 ? _a : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.indoorOutdoor,
17680
17680
  surfaceCategory: (_b = event.surfaceCategory) !== null && _b !== void 0 ? _b : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.surfaceCategory,
@@ -17714,7 +17714,7 @@ function allEventMatchUps(params) {
17714
17714
  event: event,
17715
17715
  }).scheduleTiming;
17716
17716
  var matchUps = drawDefinitions.flatMap(function (drawDefinition) {
17717
- var _a = getAllDrawMatchUps({
17717
+ var matchUps = getAllDrawMatchUps({
17718
17718
  tournamentParticipants: participants,
17719
17719
  tournamentAppliedPolicies: tournamentAppliedPolicies,
17720
17720
  scheduleVisibilityFilters: scheduleVisibilityFilters,
@@ -17733,12 +17733,10 @@ function allEventMatchUps(params) {
17733
17733
  nextMatchUps: nextMatchUps,
17734
17734
  inContext: inContext,
17735
17735
  event: event,
17736
- }), matchUps = _a.matchUps, matchUpsMap = _a.matchUpsMap;
17737
- if (matchUpsMap === null || matchUpsMap === void 0 ? void 0 : matchUpsMap.drawMatchUps)
17738
- eventMatchUps.push.apply(eventMatchUps, __spreadArray([], __read(matchUpsMap.drawMatchUps), false));
17736
+ }).matchUps;
17739
17737
  return matchUps !== null && matchUps !== void 0 ? matchUps : [];
17740
17738
  });
17741
- return { matchUps: matchUps, eventMatchUps: eventMatchUps };
17739
+ return { matchUps: matchUps };
17742
17740
  }
17743
17741
  function tournamentMatchUps(params) {
17744
17742
  var _a, _b, _c;
@@ -30155,14 +30153,15 @@ function getEventEntries(_a) {
30155
30153
  }
30156
30154
 
30157
30155
  function getParticipants$1(params) {
30158
- var withIndividualParticipants = params.withIndividualParticipants, _a = params.participantFilters, participantFilters = _a === void 0 ? {} : _a, withPotentialMatchUps = params.withPotentialMatchUps, withRankingProfile = params.withRankingProfile, convertExtensions = params.convertExtensions, policyDefinitions = params.policyDefinitions, withScheduleItems = params.withScheduleItems, tournamentRecord = params.tournamentRecord, scheduleAnalysis = params.scheduleAnalysis, withSignInStatus = params.withSignInStatus, withTeamMatchUps = params.withTeamMatchUps, withScaleValues = params.withScaleValues, usePublishState = params.usePublishState, contextProfile = params.contextProfile, withStatistics = params.withStatistics, withOpponents = params.withOpponents, withMatchUps = params.withMatchUps, internalUse = params.internalUse, withSeeding = params.withSeeding, withEvents = params.withEvents, withDraws = params.withDraws, withISO2 = params.withISO2, withIOC = params.withIOC;
30156
+ var e_1, _a, e_2, _b, e_3, _c;
30157
+ var _d;
30158
+ var withIndividualParticipants = params.withIndividualParticipants, _e = params.participantFilters, participantFilters = _e === void 0 ? {} : _e, withPotentialMatchUps = params.withPotentialMatchUps, withRankingProfile = params.withRankingProfile, convertExtensions = params.convertExtensions, policyDefinitions = params.policyDefinitions, withScheduleItems = params.withScheduleItems, tournamentRecord = params.tournamentRecord, scheduleAnalysis = params.scheduleAnalysis, withSignInStatus = params.withSignInStatus, withTeamMatchUps = params.withTeamMatchUps, withScaleValues = params.withScaleValues, usePublishState = params.usePublishState, contextProfile = params.contextProfile, withStatistics = params.withStatistics, withOpponents = params.withOpponents, withMatchUps = params.withMatchUps, internalUse = params.internalUse, withSeeding = params.withSeeding, withEvents = params.withEvents, withDraws = params.withDraws, withISO2 = params.withISO2, withIOC = params.withIOC;
30159
30159
  if (!tournamentRecord)
30160
30160
  return { error: MISSING_TOURNAMENT_RECORD };
30161
30161
  if (withMatchUps || withRankingProfile) {
30162
30162
  getMatchUpDependencies({ tournamentRecord: tournamentRecord }); // ensure goesTos are present
30163
30163
  }
30164
30164
  var participantMap = getParticipantMap({
30165
- withIndividualParticipants: withIndividualParticipants,
30166
30165
  convertExtensions: convertExtensions,
30167
30166
  tournamentRecord: tournamentRecord,
30168
30167
  withSignInStatus: withSignInStatus,
@@ -30195,7 +30194,7 @@ function getParticipants$1(params) {
30195
30194
  var matchUps = entriesResult.matchUps;
30196
30195
  participantMap = entriesResult.participantMap;
30197
30196
  var nextMatchUps = scheduleAnalysis !== null && scheduleAnalysis !== void 0 ? scheduleAnalysis : withPotentialMatchUps;
30198
- var processedParticipants = Object.values(participantMap).map(function (_a) {
30197
+ var processParticipant = function (_a) {
30199
30198
  var potentialMatchUps = _a.potentialMatchUps, scheduleConflicts = _a.scheduleConflicts, scheduleItems = _a.scheduleItems, participant = _a.participant, statistics = _a.statistics, opponents = _a.opponents, matchUps = _a.matchUps, events = _a.events, draws = _a.draws;
30200
30199
  var participantDraws = Object.values(draws);
30201
30200
  var participantOpponents = Object.values(opponents);
@@ -30204,14 +30203,27 @@ function getParticipants$1(params) {
30204
30203
  draw.opponents = participantOpponents.filter(function (opponent) { return opponent.drawId === draw.drawId; });
30205
30204
  });
30206
30205
  }
30207
- return definedAttributes(__assign(__assign({}, participant), { scheduleConflicts: scheduleAnalysis ? scheduleConflicts : undefined, draws: withDraws || withRankingProfile ? participantDraws : undefined, events: withEvents || withRankingProfile
30208
- ? Object.values(events)
30209
- : undefined, matchUps: withMatchUps || withRankingProfile
30206
+ return definedAttributes(__assign(__assign({}, participant), { scheduleConflicts: scheduleAnalysis ? scheduleConflicts : undefined, draws: withDraws || withRankingProfile ? participantDraws : undefined, events: withEvents || withRankingProfile ? Object.values(events) : undefined, matchUps: withMatchUps || withRankingProfile
30210
30207
  ? Object.values(matchUps)
30211
30208
  : undefined, opponents: withOpponents ? participantOpponents : undefined, potentialMatchUps: nextMatchUps
30212
30209
  ? Object.values(potentialMatchUps)
30213
30210
  : undefined, statistics: withStatistics ? Object.values(statistics) : undefined, scheduleItems: withScheduleItems ? scheduleItems : undefined }), false, false, true);
30214
- });
30211
+ };
30212
+ var ppMap = new Map();
30213
+ try {
30214
+ for (var _f = __values(Object.keys(participantMap)), _g = _f.next(); !_g.done; _g = _f.next()) {
30215
+ var participantId = _g.value;
30216
+ ppMap.set(participantId, processParticipant(participantMap[participantId]));
30217
+ }
30218
+ }
30219
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
30220
+ finally {
30221
+ try {
30222
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
30223
+ }
30224
+ finally { if (e_1) throw e_1.error; }
30225
+ }
30226
+ var processedParticipants = __spreadArray([], __read(ppMap.values()), false);
30215
30227
  var participantAttributes = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_PARTICIPANT];
30216
30228
  var template = participantAttributes === null || participantAttributes === void 0 ? void 0 : participantAttributes.participant;
30217
30229
  // filter must be last so attributes can be used for reporting & etc.
@@ -30220,6 +30232,35 @@ function getParticipants$1(params) {
30220
30232
  participantFilters: participantFilters,
30221
30233
  tournamentRecord: tournamentRecord,
30222
30234
  });
30235
+ if (withIndividualParticipants) {
30236
+ try {
30237
+ for (var filteredParticipants_1 = __values(filteredParticipants), filteredParticipants_1_1 = filteredParticipants_1.next(); !filteredParticipants_1_1.done; filteredParticipants_1_1 = filteredParticipants_1.next()) {
30238
+ var participant = filteredParticipants_1_1.value;
30239
+ try {
30240
+ for (var _h = (e_3 = void 0, __values((_d = participant.individualParticipantIds) !== null && _d !== void 0 ? _d : [])), _j = _h.next(); !_j.done; _j = _h.next()) {
30241
+ var individualParticipantId = _j.value;
30242
+ if (!participant.individualParticipants)
30243
+ participant.individualParticipants = [];
30244
+ participant.individualParticipants.push(ppMap.get(individualParticipantId));
30245
+ }
30246
+ }
30247
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
30248
+ finally {
30249
+ try {
30250
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
30251
+ }
30252
+ finally { if (e_3) throw e_3.error; }
30253
+ }
30254
+ }
30255
+ }
30256
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
30257
+ finally {
30258
+ try {
30259
+ if (filteredParticipants_1_1 && !filteredParticipants_1_1.done && (_b = filteredParticipants_1.return)) _b.call(filteredParticipants_1);
30260
+ }
30261
+ finally { if (e_2) throw e_2.error; }
30262
+ }
30263
+ }
30223
30264
  var participants = template
30224
30265
  ? filteredParticipants.map(function (source) {
30225
30266
  return attributeFilter({ source: source, template: template });
@@ -63994,7 +64035,7 @@ function aggregateTieFormats(_a) {
63994
64035
  }
63995
64036
  var setTieFormatId = function (matchUpId, tieFormatId) {
63996
64037
  var _a;
63997
- var matchUp = (_a = eventMatchUpResult.eventMatchUps) === null || _a === void 0 ? void 0 : _a.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
64038
+ var matchUp = (_a = eventMatchUpResult.matchUps) === null || _a === void 0 ? void 0 : _a.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
63998
64039
  if (matchUp) {
63999
64040
  matchUp.tieFormatId = tieFormatId;
64000
64041
  delete matchUp.tieFormat;
@@ -64314,7 +64355,7 @@ function getMaxEntryPosition(params) {
64314
64355
  function getPredictiveAccuracy(params) {
64315
64356
  var _a, _b, _c, _d, _e, _f, _g;
64316
64357
  var matchUps = params.matchUps;
64317
- var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, excludeMargin = params.excludeMargin, exclusionRule = params.exclusionRule, zoneDoubling = params.zoneDoubling, matchUpType = params.matchUpType, scaleName = params.scaleName, eventId = params.eventId, zonePct = params.zonePct, drawId = params.drawId, event = params.event;
64358
+ var singlesForDoubles = params.singlesForDoubles, tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, excludeMargin = params.excludeMargin, exclusionRule = params.exclusionRule, zoneDoubling = params.zoneDoubling, matchUpType = params.matchUpType, scaleName = params.scaleName, eventId = params.eventId, zonePct = params.zonePct, drawId = params.drawId, event = params.event;
64318
64359
  if (!tournamentRecord && !matchUps)
64319
64360
  return { error: MISSING_TOURNAMENT_RECORD };
64320
64361
  if (matchUpType && ![SINGLES$1, DOUBLES$1].includes(matchUpType))
@@ -64397,6 +64438,7 @@ function getPredictiveAccuracy(params) {
64397
64438
  .map(function (_a) {
64398
64439
  var competitiveProfile = _a.competitiveProfile, matchUpType = _a.matchUpType, score = _a.score, sides = _a.sides;
64399
64440
  var sideValues = getSideValues({
64441
+ singlesForDoubles: singlesForDoubles,
64400
64442
  valueAccessor: valueAccessor,
64401
64443
  matchUpType: matchUpType,
64402
64444
  scaleName: scaleName,
@@ -64448,7 +64490,7 @@ function getGroupingBands(_a) {
64448
64490
  return bands;
64449
64491
  }
64450
64492
  function getSideValues(_a) {
64451
- var exclusionRule = _a.exclusionRule, valueAccessor = _a.valueAccessor, matchUpType = _a.matchUpType, scaleName = _a.scaleName, sides = _a.sides;
64493
+ var singlesForDoubles = _a.singlesForDoubles, exclusionRule = _a.exclusionRule, valueAccessor = _a.valueAccessor, matchUpType = _a.matchUpType, scaleName = _a.scaleName, sides = _a.sides;
64452
64494
  var sortedRange = exclusionRule === null || exclusionRule === void 0 ? void 0 : exclusionRule.range.sort();
64453
64495
  var checkExcludeParticipant = function (scaleValue) {
64454
64496
  var exclusionValue = scaleValue === null || scaleValue === void 0 ? void 0 : scaleValue[exclusionRule === null || exclusionRule === void 0 ? void 0 : exclusionRule.valueAccessor];
@@ -64471,6 +64513,7 @@ function getSideValues(_a) {
64471
64513
  for (var individualParticipants_1 = __values(individualParticipants), individualParticipants_1_1 = individualParticipants_1.next(); !individualParticipants_1_1.done; individualParticipants_1_1 = individualParticipants_1.next()) {
64472
64514
  var participant_1 = individualParticipants_1_1.value;
64473
64515
  var _c = getSideValue({
64516
+ singlesForDoubles: singlesForDoubles,
64474
64517
  valueAccessor: valueAccessor,
64475
64518
  participant: participant_1,
64476
64519
  matchUpType: matchUpType,
@@ -64504,6 +64547,7 @@ function getSideValues(_a) {
64504
64547
  }
64505
64548
  else if (participant) {
64506
64549
  var _e = getSideValue({
64550
+ singlesForDoubles: singlesForDoubles,
64507
64551
  valueAccessor: valueAccessor,
64508
64552
  matchUpType: matchUpType,
64509
64553
  participant: participant,
@@ -64526,9 +64570,10 @@ function getSideValues(_a) {
64526
64570
  }
64527
64571
  function getSideValue(_a) {
64528
64572
  var _b, _c, _d, _e, _f;
64529
- var participant = _a.participant, valueAccessor = _a.valueAccessor, matchUpType = _a.matchUpType, scaleName = _a.scaleName;
64530
- var ranking = (_c = (_b = participant === null || participant === void 0 ? void 0 : participant.rankings) === null || _b === void 0 ? void 0 : _b[matchUpType]) === null || _c === void 0 ? void 0 : _c.find(function (ranking) { return ranking.scaleName === scaleName; });
64531
- var rating = (_e = (_d = participant === null || participant === void 0 ? void 0 : participant.ratings) === null || _d === void 0 ? void 0 : _d[matchUpType]) === null || _e === void 0 ? void 0 : _e.find(function (rating) { return rating.scaleName === scaleName; });
64573
+ var singlesForDoubles = _a.singlesForDoubles, valueAccessor = _a.valueAccessor, matchUpType = _a.matchUpType, participant = _a.participant, scaleName = _a.scaleName;
64574
+ var type = singlesForDoubles ? SINGLES$1 : matchUpType;
64575
+ var ranking = (_c = (_b = participant === null || participant === void 0 ? void 0 : participant.rankings) === null || _b === void 0 ? void 0 : _b[type]) === null || _c === void 0 ? void 0 : _c.find(function (ranking) { return ranking.scaleName === scaleName; });
64576
+ var rating = (_e = (_d = participant === null || participant === void 0 ? void 0 : participant.ratings) === null || _d === void 0 ? void 0 : _d[type]) === null || _e === void 0 ? void 0 : _e.find(function (rating) { return rating.scaleName === scaleName; });
64532
64577
  var scaleValue = (_f = (rating || ranking)) === null || _f === void 0 ? void 0 : _f.scaleValue;
64533
64578
  var value = valueAccessor ? scaleValue === null || scaleValue === void 0 ? void 0 : scaleValue[valueAccessor] : scaleValue;
64534
64579
  return { scaleValue: scaleValue, value: value };
@@ -64764,7 +64809,7 @@ function getEvent(_a) {
64764
64809
  }
64765
64810
  function getEvents(_a) {
64766
64811
  var e_1, _b;
64767
- var _c, _d, _e, _f, _g, _h, _j, _k;
64812
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
64768
64813
  var tournamentRecord = _a.tournamentRecord, withScaleValues = _a.withScaleValues, scaleEventType = _a.scaleEventType, inContext = _a.inContext, eventIds = _a.eventIds, drawIds = _a.drawIds, context = _a.context;
64769
64814
  if (!tournamentRecord)
64770
64815
  return { error: MISSING_TOURNAMENT_RECORD };
@@ -64792,7 +64837,7 @@ function getEvents(_a) {
64792
64837
  return values.reduce(function (total, value) { return total + parseFloat(value); }, 0);
64793
64838
  };
64794
64839
  var _loop_1 = function (event_1) {
64795
- var e_2, _l, e_3, _m, e_4, _o, e_5, _p, e_6, _q, e_7, _r, e_8, _s;
64840
+ var e_2, _o, e_3, _p, e_4, _q, e_5, _r, e_6, _s, e_7, _t, e_8, _u;
64796
64841
  var eventType = scaleEventType !== null && scaleEventType !== void 0 ? scaleEventType : event_1.eventType;
64797
64842
  var eventId = event_1.eventId;
64798
64843
  if (!eventsMap[eventId])
@@ -64840,8 +64885,8 @@ function getEvents(_a) {
64840
64885
  var participant = (_e = participantMap_1 === null || participantMap_1 === void 0 ? void 0 : participantMap_1[participantId]) === null || _e === void 0 ? void 0 : _e.participant;
64841
64886
  if ((participant === null || participant === void 0 ? void 0 : participant.participantType) !== INDIVIDUAL) {
64842
64887
  try {
64843
- for (var _t = (e_3 = void 0, __values((_f = participant === null || participant === void 0 ? void 0 : participant.individualParticipantIds) !== null && _f !== void 0 ? _f : [])), _u = _t.next(); !_u.done; _u = _t.next()) {
64844
- var individualParticipantId = _u.value;
64888
+ for (var _v = (e_3 = void 0, __values((_f = participant === null || participant === void 0 ? void 0 : participant.individualParticipantIds) !== null && _f !== void 0 ? _f : [])), _w = _v.next(); !_w.done; _w = _v.next()) {
64889
+ var individualParticipantId = _w.value;
64845
64890
  var individualParticipant = (_g = participantMap_1 === null || participantMap_1 === void 0 ? void 0 : participantMap_1[individualParticipantId]) === null || _g === void 0 ? void 0 : _g.participant;
64846
64891
  processParticipant(individualParticipant);
64847
64892
  }
@@ -64849,7 +64894,7 @@ function getEvents(_a) {
64849
64894
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
64850
64895
  finally {
64851
64896
  try {
64852
- if (_u && !_u.done && (_m = _t.return)) _m.call(_t);
64897
+ if (_w && !_w.done && (_p = _v.return)) _p.call(_v);
64853
64898
  }
64854
64899
  finally { if (e_3) throw e_3.error; }
64855
64900
  }
@@ -64862,27 +64907,31 @@ function getEvents(_a) {
64862
64907
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
64863
64908
  finally {
64864
64909
  try {
64865
- if (participantIds_1_1 && !participantIds_1_1.done && (_l = participantIds_1.return)) _l.call(participantIds_1);
64910
+ if (participantIds_1_1 && !participantIds_1_1.done && (_o = participantIds_1.return)) _o.call(participantIds_1);
64866
64911
  }
64867
64912
  finally { if (e_2) throw e_2.error; }
64868
64913
  }
64869
64914
  // add stats for all event-level entries ratings
64870
64915
  var ratings = eventsMap[eventId].ratings;
64871
64916
  try {
64872
- for (var _v = (e_4 = void 0, __values(Object.keys(ratings))), _w = _v.next(); !_w.done; _w = _v.next()) {
64873
- var scaleName = _w.value;
64917
+ for (var _x = (e_4 = void 0, __values(Object.keys(ratings))), _y = _x.next(); !_y.done; _y = _x.next()) {
64918
+ var scaleName = _y.value;
64919
+ var scaleRating = ratings[scaleName];
64920
+ if (!scaleRating.length)
64921
+ continue;
64922
+ var med = (_h = median(scaleRating)) === null || _h === void 0 ? void 0 : _h.toFixed(2);
64874
64923
  eventsMap[eventId].ratingsStats[scaleName] = {
64875
- avg: sum(ratings[scaleName]) / ratings[scaleName].length,
64876
- median: median(ratings[scaleName]),
64877
- max: Math.max.apply(Math, __spreadArray([], __read(ratings[scaleName]), false)),
64878
- min: Math.min.apply(Math, __spreadArray([], __read(ratings[scaleName]), false)),
64924
+ avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
64925
+ median: med ? parseFloat(med) : undefined,
64926
+ max: Math.max.apply(Math, __spreadArray([], __read(scaleRating), false)),
64927
+ min: Math.min.apply(Math, __spreadArray([], __read(scaleRating), false)),
64879
64928
  };
64880
64929
  }
64881
64930
  }
64882
64931
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
64883
64932
  finally {
64884
64933
  try {
64885
- if (_w && !_w.done && (_o = _v.return)) _o.call(_v);
64934
+ if (_y && !_y.done && (_q = _x.return)) _q.call(_x);
64886
64935
  }
64887
64936
  finally { if (e_4) throw e_4.error; }
64888
64937
  }
@@ -64956,14 +65005,14 @@ function getEvents(_a) {
64956
65005
  processedDrawIds.includes(drawId);
64957
65006
  };
64958
65007
  try {
64959
- for (var _x = (e_5 = void 0, __values((_h = event_1.drawDefinitions) !== null && _h !== void 0 ? _h : [])), _y = _x.next(); !_y.done; _y = _x.next()) {
64960
- var drawDefinition = _y.value;
65008
+ for (var _z = (e_5 = void 0, __values((_j = event_1.drawDefinitions) !== null && _j !== void 0 ? _j : [])), _0 = _z.next(); !_0.done; _0 = _z.next()) {
65009
+ var drawDefinition = _0.value;
64961
65010
  var drawId = drawDefinition.drawId;
64962
65011
  if (ignoreDrawId(drawId))
64963
65012
  continue;
64964
- var participantIds_2 = (_j = getAssignedParticipantIds({
65013
+ var participantIds_2 = (_k = getAssignedParticipantIds({
64965
65014
  drawDefinition: drawDefinition,
64966
- }).assignedParticipantIds) !== null && _j !== void 0 ? _j : [];
65015
+ }).assignedParticipantIds) !== null && _k !== void 0 ? _k : [];
64967
65016
  if (!eventsMap[eventId].draws[drawId])
64968
65017
  eventsMap[eventId].draws[drawId] = {
64969
65018
  ratingsStats: {},
@@ -64977,14 +65026,14 @@ function getEvents(_a) {
64977
65026
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
64978
65027
  finally {
64979
65028
  try {
64980
- if (_y && !_y.done && (_p = _x.return)) _p.call(_x);
65029
+ if (_0 && !_0.done && (_r = _z.return)) _r.call(_z);
64981
65030
  }
64982
65031
  finally { if (e_5) throw e_5.error; }
64983
65032
  }
64984
65033
  var flightProfile = getFlightProfile({ event: event_1 }).flightProfile;
64985
65034
  try {
64986
- for (var _z = (e_6 = void 0, __values((_k = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) !== null && _k !== void 0 ? _k : [])), _0 = _z.next(); !_0.done; _0 = _z.next()) {
64987
- var flight = _0.value;
65035
+ for (var _1 = (e_6 = void 0, __values((_l = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) !== null && _l !== void 0 ? _l : [])), _2 = _1.next(); !_2.done; _2 = _1.next()) {
65036
+ var flight = _2.value;
64988
65037
  var drawId = flight.drawId;
64989
65038
  if (ignoreDrawId(drawId))
64990
65039
  continue;
@@ -64995,7 +65044,7 @@ function getEvents(_a) {
64995
65044
  catch (e_6_1) { e_6 = { error: e_6_1 }; }
64996
65045
  finally {
64997
65046
  try {
64998
- if (_0 && !_0.done && (_q = _z.return)) _q.call(_z);
65047
+ if (_2 && !_2.done && (_s = _1.return)) _s.call(_1);
64999
65048
  }
65000
65049
  finally { if (e_6) throw e_6.error; }
65001
65050
  }
@@ -65004,20 +65053,24 @@ function getEvents(_a) {
65004
65053
  var drawId = processedDrawIds_1_1.value;
65005
65054
  var ratings_1 = eventsMap[eventId].draws[drawId].ratings;
65006
65055
  try {
65007
- for (var _1 = (e_8 = void 0, __values(Object.keys(ratings_1))), _2 = _1.next(); !_2.done; _2 = _1.next()) {
65008
- var scaleName = _2.value;
65056
+ for (var _3 = (e_8 = void 0, __values(Object.keys(ratings_1))), _4 = _3.next(); !_4.done; _4 = _3.next()) {
65057
+ var scaleName = _4.value;
65058
+ var scaleRating = ratings_1[scaleName];
65059
+ if (!scaleRating.length)
65060
+ continue;
65061
+ var med = (_m = median(scaleRating)) === null || _m === void 0 ? void 0 : _m.toFixed(2);
65009
65062
  eventsMap[eventId].draws[drawId].ratingsStats[scaleName] = {
65010
- avg: sum(ratings_1[scaleName]) / ratings_1[scaleName].length,
65011
- max: Math.max.apply(Math, __spreadArray([], __read(ratings_1[scaleName]), false)),
65012
- min: Math.min.apply(Math, __spreadArray([], __read(ratings_1[scaleName]), false)),
65013
- median: median(ratings_1[scaleName]),
65063
+ avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
65064
+ median: med ? parseFloat(med) : undefined,
65065
+ max: Math.max.apply(Math, __spreadArray([], __read(scaleRating), false)),
65066
+ min: Math.min.apply(Math, __spreadArray([], __read(scaleRating), false)),
65014
65067
  };
65015
65068
  }
65016
65069
  }
65017
65070
  catch (e_8_1) { e_8 = { error: e_8_1 }; }
65018
65071
  finally {
65019
65072
  try {
65020
- if (_2 && !_2.done && (_s = _1.return)) _s.call(_1);
65073
+ if (_4 && !_4.done && (_u = _3.return)) _u.call(_3);
65021
65074
  }
65022
65075
  finally { if (e_8) throw e_8.error; }
65023
65076
  }
@@ -65026,7 +65079,7 @@ function getEvents(_a) {
65026
65079
  catch (e_7_1) { e_7 = { error: e_7_1 }; }
65027
65080
  finally {
65028
65081
  try {
65029
- if (processedDrawIds_1_1 && !processedDrawIds_1_1.done && (_r = processedDrawIds_1.return)) _r.call(processedDrawIds_1);
65082
+ if (processedDrawIds_1_1 && !processedDrawIds_1_1.done && (_t = processedDrawIds_1.return)) _t.call(processedDrawIds_1);
65030
65083
  }
65031
65084
  finally { if (e_7) throw e_7.error; }
65032
65085
  }