tods-competition-factory 1.7.18 → 1.8.0
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/forge/generate.mjs +1055 -1122
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +2 -2
- package/dist/forge/query.mjs +2013 -904
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +7 -19
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +2672 -2645
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +3038 -3010
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +3 -3
package/dist/forge/generate.mjs
CHANGED
|
@@ -1279,68 +1279,16 @@ function UUID() {
|
|
|
1279
1279
|
const APPLIED_POLICIES = "appliedPolicies";
|
|
1280
1280
|
const AUDIT_POSITION_ACTIONS = "positionActions";
|
|
1281
1281
|
const CONTEXT = "context";
|
|
1282
|
-
const DELEGATED_OUTCOME = "delegatedOutcome";
|
|
1283
|
-
const DISABLED = "disabled";
|
|
1284
1282
|
const DISABLE_LINKS = "disableLinks";
|
|
1285
1283
|
const DISABLE_AUTO_CALC = "disableAutoCalc";
|
|
1286
|
-
const DRAW_DELETIONS = "drawDeletions";
|
|
1287
|
-
const DRAW_PROFILE = "drawProfile";
|
|
1288
1284
|
const ENTRY_PROFILE = "entryProfile";
|
|
1289
|
-
const EVENT_PROFILE = "eventProfile";
|
|
1290
|
-
const FACTORY = "factory";
|
|
1291
1285
|
const FLIGHT_PROFILE = "flightProfile";
|
|
1292
|
-
const GROUPING_ATTRIBUTE = "groupingAttribute";
|
|
1293
1286
|
const LINEUPS = "lineUps";
|
|
1294
1287
|
const LINKED_TOURNAMENTS = "linkedTournamentsIds";
|
|
1295
|
-
const MATCHUP_HISTORY = "matchUpHistory";
|
|
1296
|
-
const PARTICIPANT_REPRESENTATIVES = "participantRepresentatives";
|
|
1297
|
-
const PERSON_REQUESTS = "personRequests";
|
|
1298
|
-
const RANKING_POINTS = "rankingPoints";
|
|
1299
1288
|
const ROUND_TARGET = "roundTarget";
|
|
1300
|
-
const SCHEDULE_LIMITS = "scheduleLimits";
|
|
1301
1289
|
const SCHEDULE_TIMING = "scheduleTiming";
|
|
1302
|
-
const SCHEDULING_PROFILE = "schedulingProfile";
|
|
1303
|
-
const STATUS_DETAIL = "statusDetail";
|
|
1304
1290
|
const SUB_ORDER = "subOrder";
|
|
1305
1291
|
const TALLY = "tally";
|
|
1306
|
-
const TIE_FORMAT_MODIFICATIONS = "tieFormatModification";
|
|
1307
|
-
const extensionConstants = {
|
|
1308
|
-
APPLIED_POLICIES,
|
|
1309
|
-
AUDIT_POSITION_ACTIONS,
|
|
1310
|
-
CONTEXT,
|
|
1311
|
-
// used to capture, e.g. context in which a venue was added
|
|
1312
|
-
DELEGATED_OUTCOME,
|
|
1313
|
-
DISABLED,
|
|
1314
|
-
DISABLE_LINKS,
|
|
1315
|
-
DISABLE_AUTO_CALC,
|
|
1316
|
-
DRAW_DELETIONS,
|
|
1317
|
-
DRAW_PROFILE,
|
|
1318
|
-
ENTRY_PROFILE,
|
|
1319
|
-
// used for drawGeneration; not relevant for anonymized tournaments
|
|
1320
|
-
EVENT_PROFILE,
|
|
1321
|
-
FLIGHT_PROFILE,
|
|
1322
|
-
GROUPING_ATTRIBUTE,
|
|
1323
|
-
// for generating teams; not relevant for anonymized tournaments
|
|
1324
|
-
LINEUPS,
|
|
1325
|
-
LINKED_TOURNAMENTS,
|
|
1326
|
-
MATCHUP_HISTORY,
|
|
1327
|
-
PARTICIPANT_REPRESENTATIVES,
|
|
1328
|
-
PERSON_REQUESTS,
|
|
1329
|
-
RANKING_POINTS,
|
|
1330
|
-
// for attaching points awarded to tournamentRecord
|
|
1331
|
-
ROUND_TARGET,
|
|
1332
|
-
SCHEDULE_LIMITS,
|
|
1333
|
-
SCHEDULE_TIMING,
|
|
1334
|
-
SCHEDULING_PROFILE,
|
|
1335
|
-
STATUS_DETAIL,
|
|
1336
|
-
// attached to event.entries
|
|
1337
|
-
SUB_ORDER,
|
|
1338
|
-
TALLY,
|
|
1339
|
-
TIE_FORMAT_MODIFICATIONS,
|
|
1340
|
-
// for auditing, not important when anonymized
|
|
1341
|
-
FACTORY
|
|
1342
|
-
// used for capturing versioning of factory and other TODS document processors
|
|
1343
|
-
};
|
|
1344
1292
|
|
|
1345
1293
|
function getAppliedPolicies({
|
|
1346
1294
|
onlySpecifiedPolicyTypes = false,
|
|
@@ -1794,9 +1742,7 @@ function getScheduleTiming({
|
|
|
1794
1742
|
return { scheduleTiming };
|
|
1795
1743
|
}
|
|
1796
1744
|
|
|
1797
|
-
const SINGLES_MATCHUP = "SINGLES";
|
|
1798
1745
|
const SINGLES$1 = "SINGLES";
|
|
1799
|
-
const DOUBLES_MATCHUP = "DOUBLES";
|
|
1800
1746
|
const DOUBLES$1 = "DOUBLES";
|
|
1801
1747
|
const TEAM_MATCHUP = "TEAM";
|
|
1802
1748
|
const TEAM$2 = "TEAM";
|
|
@@ -7596,24 +7542,6 @@ function getTimeItem({
|
|
|
7596
7542
|
return { info: NOT_FOUND };
|
|
7597
7543
|
}
|
|
7598
7544
|
}
|
|
7599
|
-
function getEventTimeItem({
|
|
7600
|
-
returnPreviousValues,
|
|
7601
|
-
itemSubTypes,
|
|
7602
|
-
itemType,
|
|
7603
|
-
event
|
|
7604
|
-
}) {
|
|
7605
|
-
if (!event)
|
|
7606
|
-
return { error: MISSING_EVENT };
|
|
7607
|
-
if (!event.timeItems)
|
|
7608
|
-
return { info: NOT_FOUND };
|
|
7609
|
-
const { timeItem, previousItems, info } = getTimeItem({
|
|
7610
|
-
returnPreviousValues,
|
|
7611
|
-
element: event,
|
|
7612
|
-
itemSubTypes,
|
|
7613
|
-
itemType
|
|
7614
|
-
});
|
|
7615
|
-
return timeItem && { timeItem, previousItems } || { info };
|
|
7616
|
-
}
|
|
7617
7545
|
|
|
7618
7546
|
const typeMap = {
|
|
7619
7547
|
[GROUP]: "groupParticipantIds",
|
|
@@ -7627,7 +7555,6 @@ const membershipMap = {
|
|
|
7627
7555
|
function getParticipantMap({
|
|
7628
7556
|
withIndividualParticipants,
|
|
7629
7557
|
convertExtensions,
|
|
7630
|
-
policyDefinitions,
|
|
7631
7558
|
tournamentRecord,
|
|
7632
7559
|
withSignInStatus,
|
|
7633
7560
|
withScaleValues,
|
|
@@ -7635,32 +7562,23 @@ function getParticipantMap({
|
|
|
7635
7562
|
withISO2,
|
|
7636
7563
|
withIOC
|
|
7637
7564
|
}) {
|
|
7638
|
-
const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
|
|
7639
|
-
const filterAttributes = participantAttributes?.participant;
|
|
7640
7565
|
const participantMap = {};
|
|
7641
|
-
for (const participant of tournamentRecord.participants
|
|
7566
|
+
for (const participant of tournamentRecord.participants ?? []) {
|
|
7642
7567
|
const participantId = participant?.participantId;
|
|
7643
7568
|
participantId && initializeParticipantId({ participantMap, participantId });
|
|
7644
7569
|
}
|
|
7645
|
-
for (const participant of tournamentRecord.participants
|
|
7570
|
+
for (const participant of tournamentRecord.participants ?? []) {
|
|
7646
7571
|
const participantCopy = makeDeepCopy(
|
|
7647
7572
|
participant,
|
|
7648
7573
|
convertExtensions,
|
|
7649
7574
|
internalUse
|
|
7650
7575
|
);
|
|
7651
|
-
const
|
|
7652
|
-
|
|
7653
|
-
source: participantCopy
|
|
7654
|
-
}) : participantCopy;
|
|
7655
|
-
const { participantId, individualParticipantIds, participantType } = filteredParticipant;
|
|
7656
|
-
Object.assign(
|
|
7657
|
-
participantMap[participantId].participant,
|
|
7658
|
-
filteredParticipant
|
|
7659
|
-
);
|
|
7576
|
+
const { participantId, individualParticipantIds, participantType } = participantCopy;
|
|
7577
|
+
Object.assign(participantMap[participantId].participant, participantCopy);
|
|
7660
7578
|
if (individualParticipantIds) {
|
|
7661
7579
|
processIndividualParticipantIds({
|
|
7662
7580
|
individualParticipantIds,
|
|
7663
|
-
|
|
7581
|
+
participantCopy,
|
|
7664
7582
|
participantMap,
|
|
7665
7583
|
participantType,
|
|
7666
7584
|
participantId
|
|
@@ -7711,7 +7629,7 @@ function addIndividualParticipants({ participantMap }) {
|
|
|
7711
7629
|
}
|
|
7712
7630
|
function processIndividualParticipantIds({
|
|
7713
7631
|
individualParticipantIds,
|
|
7714
|
-
|
|
7632
|
+
participantCopy,
|
|
7715
7633
|
participantMap,
|
|
7716
7634
|
participantType,
|
|
7717
7635
|
participantId
|
|
@@ -7726,7 +7644,7 @@ function processIndividualParticipantIds({
|
|
|
7726
7644
|
participantName,
|
|
7727
7645
|
participantId: participantId2,
|
|
7728
7646
|
teamId
|
|
7729
|
-
} =
|
|
7647
|
+
} = participantCopy;
|
|
7730
7648
|
const membership = membershipMap[participantType];
|
|
7731
7649
|
individualParticipant[membership].push({
|
|
7732
7650
|
participantRoleResponsibilities,
|
|
@@ -7789,7 +7707,6 @@ function initializeParticipantId({ participantMap, participantId }) {
|
|
|
7789
7707
|
function hydrateParticipants({
|
|
7790
7708
|
participantsProfile,
|
|
7791
7709
|
useParticipantMap,
|
|
7792
|
-
policyDefinitions,
|
|
7793
7710
|
tournamentRecord,
|
|
7794
7711
|
contextProfile,
|
|
7795
7712
|
inContext
|
|
@@ -7798,7 +7715,6 @@ function hydrateParticipants({
|
|
|
7798
7715
|
const participantMap = getParticipantMap({
|
|
7799
7716
|
...participantsProfile,
|
|
7800
7717
|
...contextProfile,
|
|
7801
|
-
policyDefinitions,
|
|
7802
7718
|
tournamentRecord
|
|
7803
7719
|
})?.participantMap;
|
|
7804
7720
|
return { participantMap };
|
|
@@ -15262,7 +15178,7 @@ function getParticipantResults({
|
|
|
15262
15178
|
}
|
|
15263
15179
|
}
|
|
15264
15180
|
}
|
|
15265
|
-
processMatchUp
|
|
15181
|
+
processMatchUp({
|
|
15266
15182
|
matchUpFormat: tieMatchUp.matchUpFormat,
|
|
15267
15183
|
matchUpStatus: tieMatchUp.matchUpStatus,
|
|
15268
15184
|
score: tieMatchUp.score,
|
|
@@ -15282,7 +15198,7 @@ function getParticipantResults({
|
|
|
15282
15198
|
matchUpStatus
|
|
15283
15199
|
});
|
|
15284
15200
|
} else {
|
|
15285
|
-
processMatchUp
|
|
15201
|
+
processMatchUp({
|
|
15286
15202
|
matchUpFormat: matchUp.matchUpFormat || matchUpFormat,
|
|
15287
15203
|
isTieMatchUp: void 0,
|
|
15288
15204
|
winningParticipantId,
|
|
@@ -15407,7 +15323,7 @@ function processScore({
|
|
|
15407
15323
|
}
|
|
15408
15324
|
});
|
|
15409
15325
|
}
|
|
15410
|
-
function processMatchUp
|
|
15326
|
+
function processMatchUp({
|
|
15411
15327
|
winningParticipantId,
|
|
15412
15328
|
losingParticipantId,
|
|
15413
15329
|
participantResults,
|
|
@@ -17695,125 +17611,30 @@ function generateAndPopulatePlayoffStructures(params) {
|
|
|
17695
17611
|
};
|
|
17696
17612
|
}
|
|
17697
17613
|
|
|
17698
|
-
function
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
const mainPositionAssignment = derivedDrawInfo[drawId]?.mainPositionAssignments?.find(
|
|
17704
|
-
(assignment) => assignment.participantId === participantId
|
|
17705
|
-
);
|
|
17706
|
-
const qualifyingPositionAssignment = derivedDrawInfo[drawId]?.qualifyingPositionAssignments?.find(
|
|
17707
|
-
(assignment) => assignment.participantId === participantId
|
|
17708
|
-
);
|
|
17709
|
-
const positionAssignments = {};
|
|
17710
|
-
if (mainPositionAssignment) {
|
|
17711
|
-
const { participantId: participantId2, ...props } = mainPositionAssignment;
|
|
17712
|
-
if (participantId2)
|
|
17713
|
-
positionAssignments[MAIN] = { ...props };
|
|
17714
|
-
}
|
|
17715
|
-
if (qualifyingPositionAssignment) {
|
|
17716
|
-
const { participantId: participantId2, ...props } = qualifyingPositionAssignment;
|
|
17717
|
-
if (participantId2)
|
|
17718
|
-
positionAssignments[QUALIFYING] = { ...props };
|
|
17719
|
-
}
|
|
17720
|
-
return Object.keys(positionAssignments).length ? positionAssignments : void 0;
|
|
17721
|
-
}
|
|
17722
|
-
|
|
17723
|
-
function getRelevantParticipantIdsMap({
|
|
17724
|
-
processParticipantId,
|
|
17725
|
-
// optional method which is passed each participantId
|
|
17726
|
-
tournamentRecords,
|
|
17727
|
-
tournamentRecord
|
|
17728
|
-
}) {
|
|
17729
|
-
if (typeof tournamentRecord !== "object" && typeof tournamentRecords !== "object")
|
|
17730
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
17731
|
-
const allParticipants = tournamentRecords ? Object.values(tournamentRecords).map((tournamentRecord2) => tournamentRecord2?.participants || []).flat() : tournamentRecord?.participants || [];
|
|
17732
|
-
const relevantParticipantIdsMap = Object.assign(
|
|
17733
|
-
{},
|
|
17734
|
-
...allParticipants.map(
|
|
17735
|
-
({ participantId, participantType, individualParticipantIds }) => {
|
|
17736
|
-
typeof processParticipantId === "function" && processParticipantId(participantId);
|
|
17737
|
-
const individualParticipantIdObjects = (individualParticipantIds || []).map((relevantParticipantId) => ({
|
|
17738
|
-
participantType: INDIVIDUAL,
|
|
17739
|
-
relevantParticipantId
|
|
17740
|
-
}));
|
|
17741
|
-
return {
|
|
17742
|
-
[participantId]: individualParticipantIdObjects.concat({
|
|
17743
|
-
relevantParticipantId: participantId,
|
|
17744
|
-
participantType
|
|
17745
|
-
})
|
|
17746
|
-
};
|
|
17747
|
-
}
|
|
17748
|
-
)
|
|
17749
|
-
);
|
|
17750
|
-
return { relevantParticipantIdsMap };
|
|
17751
|
-
}
|
|
17752
|
-
|
|
17753
|
-
function getDerivedSeedAssignments({
|
|
17754
|
-
derivedDrawInfo,
|
|
17755
|
-
participantId,
|
|
17756
|
-
drawId
|
|
17757
|
-
}) {
|
|
17758
|
-
const mainSeedAssignment = derivedDrawInfo[drawId]?.mainSeedAssignments?.find(
|
|
17759
|
-
(assignment) => assignment.participantId === participantId
|
|
17760
|
-
);
|
|
17761
|
-
const qualifyingSeedAssignment = derivedDrawInfo[drawId]?.qualifyingSeedAssignments?.find(
|
|
17762
|
-
(assignment) => assignment.participantId === participantId
|
|
17763
|
-
);
|
|
17764
|
-
const seedAssignments = {};
|
|
17765
|
-
if (mainSeedAssignment) {
|
|
17766
|
-
const { participantId: participantId2, ...props } = mainSeedAssignment;
|
|
17767
|
-
if (participantId2)
|
|
17768
|
-
seedAssignments[MAIN] = { ...props };
|
|
17769
|
-
}
|
|
17770
|
-
if (qualifyingSeedAssignment) {
|
|
17771
|
-
const { participantId: participantId2, ...props } = qualifyingSeedAssignment;
|
|
17772
|
-
if (participantId2)
|
|
17773
|
-
seedAssignments[QUALIFYING] = { ...props };
|
|
17774
|
-
}
|
|
17775
|
-
return Object.keys(seedAssignments).length ? seedAssignments : void 0;
|
|
17776
|
-
}
|
|
17777
|
-
|
|
17778
|
-
const hasSchedule = ({
|
|
17779
|
-
scheduleAttributes = ["scheduledDate", "scheduledTime"],
|
|
17780
|
-
schedule = {}
|
|
17781
|
-
}) => {
|
|
17782
|
-
const matchUpScheduleKeys = Object.keys(schedule).filter((key) => scheduleAttributes.includes(key)).filter((key) => schedule[key]);
|
|
17783
|
-
return !!matchUpScheduleKeys.length;
|
|
17784
|
-
};
|
|
17785
|
-
|
|
17786
|
-
function participantScheduledMatchUps({
|
|
17787
|
-
scheduleAttributes = ["scheduledDate", "scheduledTime"],
|
|
17788
|
-
matchUps = []
|
|
17789
|
-
}) {
|
|
17790
|
-
if (!validMatchUps(matchUps))
|
|
17791
|
-
return { error: MISSING_MATCHUPS };
|
|
17792
|
-
if (!Array.isArray(scheduleAttributes))
|
|
17793
|
-
return { error: INVALID_VALUES };
|
|
17794
|
-
const scheduledMatchUps = matchUps.filter(Boolean).filter(({ schedule }) => hasSchedule({ schedule, scheduleAttributes })).reduce((dateMatchUps, matchUp) => {
|
|
17795
|
-
const { schedule } = matchUp;
|
|
17796
|
-
const date = extractDate(schedule?.scheduledDate);
|
|
17797
|
-
const time = extractTime(schedule?.scheduledTime);
|
|
17798
|
-
if (date && time) {
|
|
17799
|
-
if (dateMatchUps[date]) {
|
|
17800
|
-
dateMatchUps[date].push(matchUp);
|
|
17801
|
-
} else {
|
|
17802
|
-
dateMatchUps[date] = [matchUp];
|
|
17803
|
-
}
|
|
17804
|
-
}
|
|
17805
|
-
return dateMatchUps;
|
|
17806
|
-
}, {});
|
|
17807
|
-
const dates = Object.keys(scheduledMatchUps);
|
|
17808
|
-
dates.forEach((date) => {
|
|
17809
|
-
scheduledMatchUps[date].sort(
|
|
17810
|
-
(a, b) => timeSort(
|
|
17811
|
-
extractTime(a.schedule?.scheduledTime),
|
|
17812
|
-
extractTime(b.schedule?.scheduledTime)
|
|
17813
|
-
)
|
|
17814
|
-
);
|
|
17614
|
+
function getEventPublishStatuses({ event }) {
|
|
17615
|
+
const itemType = `${PUBLISH}.${STATUS}`;
|
|
17616
|
+
const { timeItem } = getTimeItem({
|
|
17617
|
+
element: event,
|
|
17618
|
+
itemType
|
|
17815
17619
|
});
|
|
17816
|
-
|
|
17620
|
+
if (timeItem?.itemValue?.PUBLIC) {
|
|
17621
|
+
const { drawIds: publishedDrawIds = [], seeding } = timeItem.itemValue.PUBLIC || {};
|
|
17622
|
+
const publishedSeeding = {
|
|
17623
|
+
published: void 0,
|
|
17624
|
+
// seeding can be present for all entries in an event when no flights have been defined
|
|
17625
|
+
seedingScaleNames: [],
|
|
17626
|
+
drawIds: []
|
|
17627
|
+
// seeding can be specific to drawIds
|
|
17628
|
+
};
|
|
17629
|
+
if (seeding) {
|
|
17630
|
+
Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
|
|
17631
|
+
}
|
|
17632
|
+
return {
|
|
17633
|
+
publishedDrawIds,
|
|
17634
|
+
publishedSeeding
|
|
17635
|
+
};
|
|
17636
|
+
}
|
|
17637
|
+
return void 0;
|
|
17817
17638
|
}
|
|
17818
17639
|
|
|
17819
17640
|
function participantScaleItem({
|
|
@@ -17855,871 +17676,968 @@ function participantScaleItem({
|
|
|
17855
17676
|
return { error: MISSING_PARTICIPANT };
|
|
17856
17677
|
}
|
|
17857
17678
|
|
|
17858
|
-
function
|
|
17859
|
-
|
|
17860
|
-
|
|
17861
|
-
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
|
|
17871
|
-
|
|
17872
|
-
|
|
17873
|
-
|
|
17874
|
-
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
17880
|
-
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
}
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
participantDraw.seedAssignments = seedAssignments;
|
|
17921
|
-
}
|
|
17679
|
+
function getEventSeedAssignments({
|
|
17680
|
+
publishedSeeding,
|
|
17681
|
+
usePublishState,
|
|
17682
|
+
withSeeding,
|
|
17683
|
+
participant,
|
|
17684
|
+
event
|
|
17685
|
+
}) {
|
|
17686
|
+
const eventSeedAssignments = {};
|
|
17687
|
+
const getScaleAccessor = (scaleName) => [SCALE, SEEDING, event.eventType, scaleName].join(".");
|
|
17688
|
+
const seedingScales = Object.assign(
|
|
17689
|
+
{},
|
|
17690
|
+
...(participant.timeItems || []).filter(({ itemType }) => itemType.split(".")[1] === SEEDING).map(({ itemType: seedingScaleName, itemValue: seedValue }) => ({
|
|
17691
|
+
[seedingScaleName]: seedValue
|
|
17692
|
+
}))
|
|
17693
|
+
);
|
|
17694
|
+
const eventSeedingScaleNames = (publishedSeeding?.stageSeedingScaleNames && Object.values(publishedSeeding?.stageSeedingScaleNames) || Array.isArray(publishedSeeding?.seedingScaleNames) && publishedSeeding.seedingScaleNames || []).map(getScaleAccessor);
|
|
17695
|
+
const publishedEventSeedingScaleNames = intersection(
|
|
17696
|
+
Object.keys(seedingScales),
|
|
17697
|
+
eventSeedingScaleNames
|
|
17698
|
+
);
|
|
17699
|
+
const eventSeedingPublished = !!(!usePublishState || !Object.keys(seedingScales).length && !publishedSeeding?.drawIds?.length || publishedEventSeedingScaleNames.length);
|
|
17700
|
+
if (eventSeedingPublished && publishedEventSeedingScaleNames.length) {
|
|
17701
|
+
if (publishedSeeding?.stageSeedingScaleNames) {
|
|
17702
|
+
const scaleValues = Object.keys(publishedSeeding.stageSeedingScaleNames).map((key) => {
|
|
17703
|
+
const accessor = getScaleAccessor(
|
|
17704
|
+
publishedSeeding.stageSeedingScaleNames[key]
|
|
17705
|
+
);
|
|
17706
|
+
const scaleValue = seedingScales[accessor];
|
|
17707
|
+
return [key, scaleValue];
|
|
17708
|
+
}).filter((pair) => pair[1]).map((pair) => ({ [pair[0]]: { seedValue: pair[1] } }));
|
|
17709
|
+
const seedAssignments = Object.assign({}, ...scaleValues);
|
|
17710
|
+
eventSeedAssignments.seedAssignments = seedAssignments;
|
|
17711
|
+
} else if (publishedEventSeedingScaleNames) {
|
|
17712
|
+
const seedValues = publishedEventSeedingScaleNames.map(
|
|
17713
|
+
(scaleName) => seedingScales[scaleName]
|
|
17714
|
+
);
|
|
17715
|
+
eventSeedAssignments.seedValue = seedValues.pop();
|
|
17716
|
+
}
|
|
17717
|
+
} else if (!usePublishState && typeof withSeeding === "object") {
|
|
17718
|
+
const scaleValues = Object.keys(withSeeding).map((key) => {
|
|
17719
|
+
const accessor = getScaleAccessor(withSeeding[key]);
|
|
17720
|
+
const scaleValue = seedingScales[accessor];
|
|
17721
|
+
return [key, scaleValue];
|
|
17722
|
+
}).filter((pair) => pair[1]).map((pair) => ({ [pair[0]]: { seedValue: pair[1] } }));
|
|
17723
|
+
const seedAssignments = Object.assign({}, ...scaleValues);
|
|
17724
|
+
eventSeedAssignments.seedAssignments = seedAssignments;
|
|
17725
|
+
} else {
|
|
17726
|
+
const { categoryName, ageCategoryCode } = event.category || {};
|
|
17727
|
+
let scaleItem;
|
|
17728
|
+
for (const scaleName of [ageCategoryCode, event.eventId, categoryName]) {
|
|
17729
|
+
const scaleAttributes = {
|
|
17730
|
+
eventType: event.eventType,
|
|
17731
|
+
scaleType: SEEDING,
|
|
17732
|
+
scaleName
|
|
17733
|
+
};
|
|
17734
|
+
const result = participantScaleItem({
|
|
17735
|
+
scaleAttributes,
|
|
17736
|
+
participant
|
|
17737
|
+
});
|
|
17738
|
+
if (result.scaleItem) {
|
|
17739
|
+
scaleItem = result.scaleItem;
|
|
17740
|
+
break;
|
|
17922
17741
|
}
|
|
17923
17742
|
}
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
[seedingScaleName]: seedValue
|
|
17932
|
-
}))
|
|
17933
|
-
);
|
|
17934
|
-
for (const participantEvent of participantEvents) {
|
|
17935
|
-
const getScaleAccessor = (scaleName) => [SCALE, SEEDING, participantEvent.eventType, scaleName].join(".");
|
|
17936
|
-
const publishedSeeding = eventsPublishStatuses[participantEvent.eventId]?.publishedSeeding;
|
|
17937
|
-
const eventSeedingScaleNames = (publishedSeeding?.stageSeedingScaleNames && Object.values(publishedSeeding?.stageSeedingScaleNames) || Array.isArray(publishedSeeding?.seedingScaleNames) && publishedSeeding.seedingScaleNames || []).map(getScaleAccessor);
|
|
17938
|
-
const publishedEventSeedingScaleNames = intersection(
|
|
17939
|
-
Object.keys(seedingScales),
|
|
17940
|
-
eventSeedingScaleNames
|
|
17941
|
-
);
|
|
17942
|
-
const eventSeedingPublished = !!(!usePublishState || !Object.keys(seedingScales).length && !publishedSeeding?.drawIds?.length || publishedEventSeedingScaleNames.length);
|
|
17943
|
-
if (eventSeedingPublished && publishedEventSeedingScaleNames.length) {
|
|
17944
|
-
if (publishedSeeding?.stageSeedingScaleNames) {
|
|
17945
|
-
const scaleValues = Object.keys(
|
|
17946
|
-
publishedSeeding.stageSeedingScaleNames
|
|
17947
|
-
).map((key) => {
|
|
17948
|
-
const accessor = getScaleAccessor(
|
|
17949
|
-
publishedSeeding.stageSeedingScaleNames[key]
|
|
17950
|
-
);
|
|
17951
|
-
const scaleValue = seedingScales[accessor];
|
|
17952
|
-
return [key, scaleValue];
|
|
17953
|
-
}).filter((pair) => pair[1]).map((pair) => ({ [pair[0]]: { seedValue: pair[1] } }));
|
|
17954
|
-
const seedAssignments = Object.assign({}, ...scaleValues);
|
|
17955
|
-
participantEvent.seedAssignments = seedAssignments;
|
|
17956
|
-
} else if (publishedEventSeedingScaleNames) {
|
|
17957
|
-
const seedValues = publishedEventSeedingScaleNames.map(
|
|
17958
|
-
(scaleName) => seedingScales[scaleName]
|
|
17959
|
-
);
|
|
17960
|
-
participantEvent.seedValue = seedValues.pop();
|
|
17961
|
-
}
|
|
17962
|
-
} else if (!usePublishState && typeof withSeeding === "object") {
|
|
17963
|
-
const scaleValues = Object.keys(withSeeding).map((key) => {
|
|
17964
|
-
const accessor = getScaleAccessor(withSeeding[key]);
|
|
17965
|
-
const scaleValue = seedingScales[accessor];
|
|
17966
|
-
return [key, scaleValue];
|
|
17967
|
-
}).filter((pair) => pair[1]).map((pair) => ({ [pair[0]]: { seedValue: pair[1] } }));
|
|
17968
|
-
const seedAssignments = Object.assign({}, ...scaleValues);
|
|
17969
|
-
participantEvent.seedAssignments = seedAssignments;
|
|
17970
|
-
} else {
|
|
17971
|
-
const { categoryName, ageCategoryCode } = participantEvent.category || {};
|
|
17972
|
-
let scaleItem;
|
|
17973
|
-
for (const scaleName of [
|
|
17974
|
-
participantEvent.eventId,
|
|
17975
|
-
ageCategoryCode,
|
|
17976
|
-
categoryName
|
|
17977
|
-
]) {
|
|
17978
|
-
const scaleAttributes = {
|
|
17979
|
-
eventType: participantEvent.eventType,
|
|
17980
|
-
scaleType: SEEDING,
|
|
17981
|
-
scaleName
|
|
17982
|
-
};
|
|
17983
|
-
const result = participantScaleItem({
|
|
17984
|
-
scaleAttributes,
|
|
17985
|
-
participant
|
|
17986
|
-
});
|
|
17987
|
-
if (result.scaleItem) {
|
|
17988
|
-
scaleItem = result.scaleItem;
|
|
17989
|
-
break;
|
|
17990
|
-
}
|
|
17991
|
-
}
|
|
17992
|
-
if (scaleItem) {
|
|
17993
|
-
const seedValue = scaleItem.scaleValue;
|
|
17994
|
-
const seedingPublished = !usePublishState || publishedSeeding?.published && (publishedSeeding?.drawIds?.length === 0 || publishedSeeding?.drawIds?.includes(
|
|
17995
|
-
participantEvent.drawId
|
|
17996
|
-
));
|
|
17997
|
-
if (seedingPublished) {
|
|
17998
|
-
participantEvent.seedValue = seedValue;
|
|
17999
|
-
}
|
|
18000
|
-
}
|
|
18001
|
-
}
|
|
18002
|
-
if (participantEvent.drawIds?.length) {
|
|
18003
|
-
for (const flightDrawId of participantEvent.drawIds || []) {
|
|
18004
|
-
const drawSeedPublishingDisabled = publishedSeeding?.drawIds?.length && !publishedSeeding?.drawIds?.includes(flightDrawId);
|
|
18005
|
-
if (eventSeedingPublished && !drawSeedPublishingDisabled) {
|
|
18006
|
-
const seedAssignments = getDerivedSeedAssignments({
|
|
18007
|
-
drawId: flightDrawId,
|
|
18008
|
-
derivedDrawInfo,
|
|
18009
|
-
participantId
|
|
18010
|
-
});
|
|
18011
|
-
if (seedAssignments && participantEvent.seedAssignments) {
|
|
18012
|
-
for (const key of Object.keys(
|
|
18013
|
-
participantEvent.seedAssignments
|
|
18014
|
-
)) {
|
|
18015
|
-
participantEvent.seedAssignments[key] = seedAssignments[key];
|
|
18016
|
-
}
|
|
18017
|
-
} else {
|
|
18018
|
-
participantEvent.seedAssignments = seedAssignments;
|
|
18019
|
-
}
|
|
18020
|
-
}
|
|
18021
|
-
}
|
|
18022
|
-
}
|
|
17743
|
+
if (scaleItem) {
|
|
17744
|
+
const seedingPublished = !usePublishState || publishedSeeding?.published && // if drawIds have been specified then don't attach event seeding here
|
|
17745
|
+
// defer to seedValue that is in seedAssignments for draw in which participant appears
|
|
17746
|
+
!publishedSeeding?.published?.drawIds?.length;
|
|
17747
|
+
if (seedingPublished) {
|
|
17748
|
+
const seedValue = scaleItem.scaleValue;
|
|
17749
|
+
eventSeedAssignments.seedValue = seedValue;
|
|
18023
17750
|
}
|
|
18024
17751
|
}
|
|
18025
17752
|
}
|
|
18026
|
-
|
|
18027
|
-
if (withOpponents && participantOpponents?.length) {
|
|
18028
|
-
participant.opponents = participantOpponents;
|
|
18029
|
-
participantDraws?.forEach((draw) => {
|
|
18030
|
-
draw.opponents = participantOpponents.filter(
|
|
18031
|
-
(opponent) => opponent.drawId === draw.drawId
|
|
18032
|
-
);
|
|
18033
|
-
});
|
|
18034
|
-
}
|
|
18035
|
-
const participantPotentialMatchUps = Object.values(potentialMatchUps);
|
|
18036
|
-
const participantMatchUps = Object.values(matchUps);
|
|
18037
|
-
if (withMatchUps) {
|
|
18038
|
-
participant.potentialMatchUps = participantPotentialMatchUps;
|
|
18039
|
-
participant.matchUps = participantMatchUps;
|
|
18040
|
-
}
|
|
18041
|
-
const allParticipantMatchUps = participantMatchUps.concat(
|
|
18042
|
-
participantPotentialMatchUps
|
|
18043
|
-
);
|
|
18044
|
-
const scheduledMatchUps = participantScheduledMatchUps({
|
|
18045
|
-
matchUps: allParticipantMatchUps
|
|
18046
|
-
})?.scheduledMatchUps || [];
|
|
18047
|
-
const { scheduledMinutesDifference } = scheduleAnalysis || {};
|
|
18048
|
-
const dates = Object.keys(scheduledMatchUps);
|
|
18049
|
-
dates.forEach((date) => {
|
|
18050
|
-
scheduledMatchUps[date].filter(Boolean).forEach((matchUp, i) => {
|
|
18051
|
-
const {
|
|
18052
|
-
schedule: {
|
|
18053
|
-
scheduledTime,
|
|
18054
|
-
timeAfterRecovery,
|
|
18055
|
-
typeChangeTimeAfterRecovery
|
|
18056
|
-
},
|
|
18057
|
-
matchUpStatus,
|
|
18058
|
-
roundPosition,
|
|
18059
|
-
structureName,
|
|
18060
|
-
matchUpType,
|
|
18061
|
-
roundNumber,
|
|
18062
|
-
matchUpId,
|
|
18063
|
-
drawId,
|
|
18064
|
-
score
|
|
18065
|
-
} = matchUp;
|
|
18066
|
-
scheduleItems.push({
|
|
18067
|
-
...matchUp.schedule,
|
|
18068
|
-
scheduledTime: extractTime(matchUp.schedule?.scheduledTime),
|
|
18069
|
-
roundPosition,
|
|
18070
|
-
structureName,
|
|
18071
|
-
matchUpType,
|
|
18072
|
-
roundNumber,
|
|
18073
|
-
matchUpId,
|
|
18074
|
-
drawId
|
|
18075
|
-
});
|
|
18076
|
-
const ignoreMatchUp = matchUpStatus === BYE || [WALKOVER$1, DEFAULTED].includes(matchUpStatus) && !scoreHasValue({ score });
|
|
18077
|
-
if (scheduledTime && !ignoreMatchUp) {
|
|
18078
|
-
const scheduledMinutes = timeStringMinutes(scheduledTime);
|
|
18079
|
-
const matchUpsToConsider = scheduledMatchUps[date].slice(i + 1);
|
|
18080
|
-
for (const consideredMatchUp of matchUpsToConsider) {
|
|
18081
|
-
const ignoreMatchUp2 = consideredMatchUp.matchUpStatus === BYE || [WALKOVER$1, DEFAULTED].includes(consideredMatchUp.matchUpStatus) && !scoreHasValue(consideredMatchUp);
|
|
18082
|
-
if (!ignoreMatchUp2 && consideredMatchUp.schedule?.scheduledTime) {
|
|
18083
|
-
const typeChange = matchUp.matchUpType !== consideredMatchUp.matchUpType;
|
|
18084
|
-
const notBeforeTime = typeChange ? typeChangeTimeAfterRecovery || timeAfterRecovery : timeAfterRecovery;
|
|
18085
|
-
const sameDraw = matchUp.drawId === consideredMatchUp.drawId;
|
|
18086
|
-
const bothPotential = matchUp.potential && consideredMatchUp.potential;
|
|
18087
|
-
const nextMinutes = timeStringMinutes(
|
|
18088
|
-
consideredMatchUp.schedule?.scheduledTime
|
|
18089
|
-
);
|
|
18090
|
-
const minutesDifference = nextMinutes - scheduledMinutes;
|
|
18091
|
-
const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : timeStringMinutes(notBeforeTime) > timeStringMinutes(consideredMatchUp.schedule?.scheduledTime);
|
|
18092
|
-
if (timeOverlap && !(bothPotential && sameDraw)) {
|
|
18093
|
-
scheduleConflicts.push({
|
|
18094
|
-
priorScheduledMatchUpId: consideredMatchUp.matchUpId,
|
|
18095
|
-
matchUpIdWithConflict: matchUpId
|
|
18096
|
-
});
|
|
18097
|
-
}
|
|
18098
|
-
}
|
|
18099
|
-
}
|
|
18100
|
-
}
|
|
18101
|
-
});
|
|
18102
|
-
});
|
|
18103
|
-
if (withStatistics)
|
|
18104
|
-
participant.statistics = [winRatioStat];
|
|
18105
|
-
return { scheduleConflicts, scheduleItems };
|
|
17753
|
+
return eventSeedAssignments;
|
|
18106
17754
|
}
|
|
18107
17755
|
|
|
18108
|
-
function
|
|
18109
|
-
|
|
18110
|
-
|
|
18111
|
-
|
|
17756
|
+
function processEventEntry({
|
|
17757
|
+
extensionConversions,
|
|
17758
|
+
seedAssignments,
|
|
17759
|
+
participant,
|
|
17760
|
+
withSeeding,
|
|
17761
|
+
seedValue,
|
|
17762
|
+
eventId,
|
|
17763
|
+
ranking,
|
|
17764
|
+
entry
|
|
18112
17765
|
}) {
|
|
18113
|
-
const
|
|
18114
|
-
const
|
|
18115
|
-
|
|
18116
|
-
...
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18120
|
-
|
|
18121
|
-
|
|
18122
|
-
|
|
18123
|
-
|
|
18124
|
-
|
|
18125
|
-
|
|
18126
|
-
|
|
18127
|
-
|
|
18128
|
-
|
|
18129
|
-
structure: mainStructure
|
|
18130
|
-
})?.positionAssignments;
|
|
18131
|
-
const drawSize = mainPositionAssignments?.length;
|
|
18132
|
-
const qualifyingStructure = getDrawStructures({
|
|
18133
|
-
stageSequence: 1,
|
|
18134
|
-
stage: QUALIFYING,
|
|
18135
|
-
drawDefinition
|
|
18136
|
-
})?.structures?.[0];
|
|
18137
|
-
const qualifyingPositionAssignments = mainStructure && getPositionAssignments({
|
|
18138
|
-
structure: qualifyingStructure
|
|
18139
|
-
})?.positionAssignments;
|
|
18140
|
-
const qualifyingDrawSize = qualifyingPositionAssignments?.length;
|
|
18141
|
-
const mainSeedAssignments = mainStructure?.seedAssignments;
|
|
18142
|
-
const qualifyingSeedAssignments = qualifyingStructure?.seedAssignments;
|
|
18143
|
-
const orderedStructureIds = (drawDefinition.structures || []).sort((a, b) => structureSort(a, b, sortConfig)).map(({ structureId, structures }) => {
|
|
18144
|
-
return [
|
|
18145
|
-
structureId,
|
|
18146
|
-
...(structures || []).map(({ structureId: structureId2 }) => structureId2)
|
|
18147
|
-
];
|
|
18148
|
-
}).flat(Infinity);
|
|
18149
|
-
const flightNumber = event?._flightProfile?.flights?.find(
|
|
18150
|
-
(flight) => flight.drawId === drawDefinition.drawId
|
|
18151
|
-
)?.flightNumber;
|
|
18152
|
-
derivedInfo[drawDefinition.drawId] = {
|
|
18153
|
-
qualifyingPositionAssignments,
|
|
18154
|
-
qualifyingSeedAssignments,
|
|
18155
|
-
mainPositionAssignments,
|
|
18156
|
-
mainSeedAssignments,
|
|
18157
|
-
orderedStructureIds,
|
|
18158
|
-
qualifyingDrawSize,
|
|
18159
|
-
flightNumber,
|
|
18160
|
-
drawSize
|
|
18161
|
-
};
|
|
18162
|
-
return {
|
|
18163
|
-
[drawDefinition.drawId]: {
|
|
18164
|
-
drawType: drawDefinition.drawType,
|
|
18165
|
-
drawEntries
|
|
18166
|
-
}
|
|
18167
|
-
};
|
|
18168
|
-
})
|
|
17766
|
+
const { entryStatus, entryStage, entryPosition, extensions } = entry;
|
|
17767
|
+
const entryExtensions = extensions?.length ? Object.assign({}, ...extensionsToAttributes(extensions)) : {};
|
|
17768
|
+
const attributes = Object.assign(entryExtensions, {
|
|
17769
|
+
...extensionConversions,
|
|
17770
|
+
// this should be deprecated and clients should use derivedEventInfo
|
|
17771
|
+
entryPosition,
|
|
17772
|
+
entryStatus,
|
|
17773
|
+
entryStage,
|
|
17774
|
+
ranking,
|
|
17775
|
+
eventId
|
|
17776
|
+
});
|
|
17777
|
+
participant.events[eventId] = definedAttributes(
|
|
17778
|
+
attributes,
|
|
17779
|
+
false,
|
|
17780
|
+
false,
|
|
17781
|
+
true
|
|
18169
17782
|
);
|
|
18170
|
-
|
|
17783
|
+
if (withSeeding) {
|
|
17784
|
+
if (seedAssignments)
|
|
17785
|
+
participant.events[eventId].seedAssignments = seedAssignments;
|
|
17786
|
+
if (seedValue)
|
|
17787
|
+
participant.events[eventId].seedValue = seedValue;
|
|
17788
|
+
}
|
|
18171
17789
|
}
|
|
18172
17790
|
|
|
18173
|
-
function
|
|
18174
|
-
relevantParticipantIdsMap,
|
|
18175
|
-
participantFilters,
|
|
18176
|
-
participantIdMap,
|
|
18177
|
-
derivedDrawInfo,
|
|
18178
|
-
eventDrawsCount,
|
|
18179
|
-
drawDetails,
|
|
18180
|
-
eventType,
|
|
18181
|
-
matchUp
|
|
18182
|
-
}) {
|
|
17791
|
+
function addScheduleItem(params) {
|
|
18183
17792
|
const {
|
|
18184
|
-
|
|
18185
|
-
|
|
18186
|
-
drawId,
|
|
18187
|
-
drawName,
|
|
18188
|
-
eventId,
|
|
18189
|
-
eventName,
|
|
18190
|
-
finishingRound,
|
|
18191
|
-
finishingPositionRange,
|
|
18192
|
-
processCodes,
|
|
18193
|
-
loserTo,
|
|
18194
|
-
matchUpId,
|
|
18195
|
-
matchUpType,
|
|
18196
|
-
matchUpFormat,
|
|
17793
|
+
participantMap,
|
|
17794
|
+
participantId,
|
|
18197
17795
|
matchUpStatus,
|
|
18198
|
-
matchUpStatusCodes,
|
|
18199
|
-
matchUpTieId,
|
|
18200
|
-
roundName,
|
|
18201
|
-
roundNumber,
|
|
18202
17796
|
roundPosition,
|
|
18203
|
-
score,
|
|
18204
|
-
sides,
|
|
18205
|
-
stage,
|
|
18206
|
-
stageSequence,
|
|
18207
|
-
schedule,
|
|
18208
|
-
structureName,
|
|
18209
17797
|
structureId,
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
const participants = (matchUp.sides?.filter(Boolean) || []).map(
|
|
18236
|
-
({ sideNumber, participantId, participant }) => sideNumber && participantId && {
|
|
18237
|
-
sideNumber,
|
|
18238
|
-
participantId,
|
|
18239
|
-
participant
|
|
18240
|
-
}
|
|
18241
|
-
).filter(Boolean);
|
|
18242
|
-
doublesTieParticipants.push(...participants);
|
|
18243
|
-
}
|
|
18244
|
-
sides?.forEach((params) => {
|
|
18245
|
-
const { participantId, sideNumber } = params;
|
|
18246
|
-
if (!participantId)
|
|
18247
|
-
return;
|
|
18248
|
-
const { drawType, drawEntries } = drawDetails[drawId];
|
|
18249
|
-
const participantScore = sideNumber === 1 ? score?.scoreStringSide1 : score?.scoreStringSide2;
|
|
18250
|
-
const participantWon = winningSide && sideNumber === winningSide;
|
|
18251
|
-
const opponent = matchUp.sides.find(
|
|
18252
|
-
(side) => side.sideNumber === 3 - sideNumber
|
|
18253
|
-
);
|
|
18254
|
-
const opponentParticipantId = opponent?.participantId;
|
|
18255
|
-
const relevantOpponents = opponentParticipantId && relevantParticipantIdsMap[opponentParticipantId] || [];
|
|
18256
|
-
const finishingPositionRange2 = participantWon ? winner : loser;
|
|
18257
|
-
const drawEntry = drawEntries.find(
|
|
18258
|
-
(entry) => entry.participantId === participantId
|
|
18259
|
-
);
|
|
18260
|
-
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
18261
|
-
const addedPairParticipantIds = [];
|
|
18262
|
-
doublesTieParticipants?.filter((participant) => participant.sideNumber === sideNumber).forEach((p) => {
|
|
18263
|
-
const participantId2 = p.participantId;
|
|
18264
|
-
if (participantId2 && !addedPairParticipantIds.includes(participantId2)) {
|
|
18265
|
-
relevantParticipantIds.push({
|
|
18266
|
-
relevantParticipantId: participantId2,
|
|
18267
|
-
participantType: PAIR
|
|
18268
|
-
});
|
|
18269
|
-
addedPairParticipantIds.push(participantId2);
|
|
18270
|
-
}
|
|
17798
|
+
matchUpType,
|
|
17799
|
+
roundNumber,
|
|
17800
|
+
matchUpId,
|
|
17801
|
+
potential,
|
|
17802
|
+
schedule,
|
|
17803
|
+
drawId,
|
|
17804
|
+
score
|
|
17805
|
+
} = params;
|
|
17806
|
+
if (!schedule || !Object.keys(schedule).length)
|
|
17807
|
+
return;
|
|
17808
|
+
const ignoreMatchUp = matchUpStatus === BYE;
|
|
17809
|
+
if (!ignoreMatchUp) {
|
|
17810
|
+
participantMap[participantId].scheduleItems.push({
|
|
17811
|
+
...schedule,
|
|
17812
|
+
scheduledDate: extractDate(schedule?.scheduledDate),
|
|
17813
|
+
scheduledTime: extractTime(schedule?.scheduledTime),
|
|
17814
|
+
scoreHasValue: scoreHasValue({ score }),
|
|
17815
|
+
matchUpStatus,
|
|
17816
|
+
roundPosition,
|
|
17817
|
+
structureId,
|
|
17818
|
+
matchUpType,
|
|
17819
|
+
roundNumber,
|
|
17820
|
+
matchUpId,
|
|
17821
|
+
potential,
|
|
17822
|
+
drawId
|
|
18271
17823
|
});
|
|
18272
|
-
|
|
18273
|
-
|
|
18274
|
-
|
|
18275
|
-
|
|
18276
|
-
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
18282
|
-
|
|
18283
|
-
|
|
18284
|
-
|
|
18285
|
-
|
|
18286
|
-
|
|
18287
|
-
|
|
18288
|
-
|
|
18289
|
-
|
|
18290
|
-
|
|
18291
|
-
|
|
18292
|
-
|
|
18293
|
-
|
|
18294
|
-
|
|
18295
|
-
|
|
18296
|
-
|
|
18297
|
-
|
|
18298
|
-
|
|
18299
|
-
|
|
18300
|
-
|
|
18301
|
-
|
|
18302
|
-
|
|
18303
|
-
|
|
18304
|
-
|
|
18305
|
-
|
|
18306
|
-
|
|
17824
|
+
}
|
|
17825
|
+
}
|
|
17826
|
+
|
|
17827
|
+
function addStructureParticipation({
|
|
17828
|
+
finishingPositionRange: matchUpFinishingPositionRanges = {},
|
|
17829
|
+
participantMap,
|
|
17830
|
+
finishingRound,
|
|
17831
|
+
participantWon,
|
|
17832
|
+
matchUpStatus,
|
|
17833
|
+
participantId,
|
|
17834
|
+
stageSequence,
|
|
17835
|
+
roundNumber,
|
|
17836
|
+
structureId,
|
|
17837
|
+
matchUpId,
|
|
17838
|
+
drawId,
|
|
17839
|
+
stage
|
|
17840
|
+
}) {
|
|
17841
|
+
const participantAggregator = participantMap[participantId];
|
|
17842
|
+
const diff = (range) => Math.abs(range[0] - range[1]);
|
|
17843
|
+
if (!participantAggregator.structureParticipation[structureId]) {
|
|
17844
|
+
participantAggregator.structureParticipation[structureId] = {
|
|
17845
|
+
rankingStage: stage,
|
|
17846
|
+
walkoverWinCount: 0,
|
|
17847
|
+
defaultWinCount: 0,
|
|
17848
|
+
stageSequence,
|
|
17849
|
+
winCount: 0,
|
|
17850
|
+
structureId,
|
|
17851
|
+
drawId
|
|
17852
|
+
};
|
|
17853
|
+
}
|
|
17854
|
+
const structureParticipation = participantAggregator.structureParticipation[structureId];
|
|
17855
|
+
const { winner, loser } = matchUpFinishingPositionRanges;
|
|
17856
|
+
const finishingPositionRange = participantWon ? winner : loser;
|
|
17857
|
+
if (participantWon) {
|
|
17858
|
+
structureParticipation.winCount += 1;
|
|
17859
|
+
if (matchUpStatus === WALKOVER$1) {
|
|
17860
|
+
structureParticipation.walkoverWinCount += 1;
|
|
17861
|
+
}
|
|
17862
|
+
if (matchUpStatus === DEFAULTED) {
|
|
17863
|
+
structureParticipation.defaultWinCount += 1;
|
|
17864
|
+
}
|
|
17865
|
+
}
|
|
17866
|
+
if (finishingPositionRange && (!structureParticipation.finishingPositionRange || diff(finishingPositionRange) < diff(structureParticipation.finishingPositionRange))) {
|
|
17867
|
+
structureParticipation.finishingPositionRange = finishingPositionRange;
|
|
17868
|
+
}
|
|
17869
|
+
if (finishingRound) {
|
|
17870
|
+
if (!structureParticipation.finishingRound || finishingRound < structureParticipation.finishingRound) {
|
|
17871
|
+
structureParticipation.finishingMatchUpId = matchUpId;
|
|
17872
|
+
structureParticipation.finishingRound = finishingRound;
|
|
17873
|
+
structureParticipation.roundNumber = roundNumber;
|
|
17874
|
+
}
|
|
17875
|
+
if (finishingRound === 1) {
|
|
17876
|
+
structureParticipation.participantWon = participantWon;
|
|
17877
|
+
}
|
|
17878
|
+
}
|
|
17879
|
+
}
|
|
17880
|
+
|
|
17881
|
+
function processSides(params) {
|
|
17882
|
+
const {
|
|
17883
|
+
withScheduleTimes,
|
|
17884
|
+
scheduleAnalysis,
|
|
17885
|
+
withTeamMatchUps,
|
|
17886
|
+
participantMap,
|
|
17887
|
+
withOpponents,
|
|
17888
|
+
withMatchUps,
|
|
17889
|
+
withEvents,
|
|
17890
|
+
withDraws,
|
|
17891
|
+
finishingPositionRange,
|
|
17892
|
+
finishingRound,
|
|
17893
|
+
matchUpStatus,
|
|
17894
|
+
stageSequence,
|
|
17895
|
+
roundNumber,
|
|
17896
|
+
structureId,
|
|
17897
|
+
score,
|
|
17898
|
+
stage,
|
|
17899
|
+
withRankingProfile,
|
|
17900
|
+
tieWinningSide,
|
|
17901
|
+
roundPosition,
|
|
17902
|
+
matchUpTieId,
|
|
17903
|
+
matchUpSides,
|
|
17904
|
+
collectionId,
|
|
17905
|
+
matchUpType,
|
|
17906
|
+
winningSide,
|
|
17907
|
+
matchUpId,
|
|
17908
|
+
schedule,
|
|
17909
|
+
eventId,
|
|
17910
|
+
drawId,
|
|
17911
|
+
sides
|
|
17912
|
+
} = params;
|
|
17913
|
+
const opponents = withOpponents && sides?.length === 2 && Object.assign(
|
|
17914
|
+
{},
|
|
17915
|
+
...sides.map(({ sideNumber }, i) => {
|
|
17916
|
+
const opponentParticipantId = sides[1 - i].participantId;
|
|
17917
|
+
return sideNumber && {
|
|
17918
|
+
[sideNumber]: opponentParticipantId
|
|
17919
|
+
};
|
|
17920
|
+
}).filter(Boolean)
|
|
17921
|
+
);
|
|
17922
|
+
for (const side of sides) {
|
|
17923
|
+
const { participantId, sideNumber, bye } = side;
|
|
17924
|
+
if (bye)
|
|
17925
|
+
continue;
|
|
17926
|
+
const participantWon = winningSide === sideNumber;
|
|
17927
|
+
const getOpponentInfo = (opponentParticipantId) => {
|
|
17928
|
+
const opponent = participantMap[opponentParticipantId]?.participant;
|
|
17929
|
+
const participantType = opponent?.participantType;
|
|
17930
|
+
const info = [
|
|
17931
|
+
{
|
|
17932
|
+
participantId: opponentParticipantId,
|
|
17933
|
+
participantType
|
|
18307
17934
|
}
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
17935
|
+
];
|
|
17936
|
+
if (participantType !== TEAM_PARTICIPANT) {
|
|
17937
|
+
for (const participantId2 of opponent?.individualParticipantIds || []) {
|
|
17938
|
+
const participant = participantMap[participantId2]?.participant;
|
|
17939
|
+
info.push({
|
|
17940
|
+
participantType: participant?.participantType,
|
|
17941
|
+
participantId: participantId2
|
|
17942
|
+
});
|
|
18315
17943
|
}
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
|
|
17944
|
+
}
|
|
17945
|
+
return info;
|
|
17946
|
+
};
|
|
17947
|
+
const addMatchUp = (participantId2, opponentParticipantId) => {
|
|
17948
|
+
if (withMatchUps) {
|
|
17949
|
+
participantMap[participantId2].matchUps[matchUpId] = {
|
|
17950
|
+
participantWon,
|
|
17951
|
+
matchUpType,
|
|
17952
|
+
structureId,
|
|
17953
|
+
sideNumber,
|
|
17954
|
+
matchUpId,
|
|
17955
|
+
eventId,
|
|
17956
|
+
drawId,
|
|
17957
|
+
stage
|
|
17958
|
+
};
|
|
17959
|
+
if (withOpponents) {
|
|
17960
|
+
const opponentParticipantInfo = getOpponentInfo(
|
|
17961
|
+
opponentParticipantId
|
|
18320
17962
|
);
|
|
17963
|
+
participantMap[participantId2].matchUps[matchUpId].opponentParticipantInfo = opponentParticipantInfo;
|
|
18321
17964
|
}
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
const relevantParticipantInfo = filteredRelevantParticipantIds.find(
|
|
18325
|
-
(participantInfo) => {
|
|
18326
|
-
return participantInfo.relevantParticipantId !== relevantParticipantId && participantInfo.participantType === INDIVIDUAL;
|
|
18327
|
-
}
|
|
18328
|
-
);
|
|
18329
|
-
partnerParticipantId = relevantParticipantInfo?.relevantParticipantId;
|
|
17965
|
+
if (collectionId) {
|
|
17966
|
+
participantMap[participantId2].matchUps[matchUpId].collectionId = collectionId;
|
|
18330
17967
|
}
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
|
|
18335
|
-
|
|
18336
|
-
|
|
18337
|
-
|
|
18338
|
-
|
|
18339
|
-
|
|
18340
|
-
|
|
18341
|
-
|
|
18342
|
-
|
|
18343
|
-
|
|
18344
|
-
|
|
18345
|
-
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
|
|
18350
|
-
|
|
18351
|
-
|
|
18352
|
-
|
|
17968
|
+
}
|
|
17969
|
+
if (withOpponents && opponentParticipantId) {
|
|
17970
|
+
participantMap[participantId2].opponents[opponentParticipantId] = {
|
|
17971
|
+
participantId: opponentParticipantId,
|
|
17972
|
+
matchUpId,
|
|
17973
|
+
eventId,
|
|
17974
|
+
drawId
|
|
17975
|
+
};
|
|
17976
|
+
}
|
|
17977
|
+
if (withRankingProfile) {
|
|
17978
|
+
addStructureParticipation({
|
|
17979
|
+
finishingPositionRange,
|
|
17980
|
+
participantMap,
|
|
17981
|
+
participantWon,
|
|
17982
|
+
finishingRound,
|
|
17983
|
+
matchUpStatus,
|
|
17984
|
+
participantId: participantId2,
|
|
17985
|
+
stageSequence,
|
|
17986
|
+
roundNumber,
|
|
17987
|
+
structureId,
|
|
17988
|
+
matchUpId,
|
|
17989
|
+
drawId,
|
|
17990
|
+
stage
|
|
17991
|
+
});
|
|
17992
|
+
}
|
|
17993
|
+
if (scheduleAnalysis || withScheduleTimes) {
|
|
17994
|
+
addScheduleItem({
|
|
17995
|
+
participantMap,
|
|
17996
|
+
participantId: participantId2,
|
|
17997
|
+
matchUpStatus,
|
|
17998
|
+
roundPosition,
|
|
17999
|
+
matchUpType,
|
|
18000
|
+
roundNumber,
|
|
18001
|
+
structureId,
|
|
18002
|
+
matchUpId,
|
|
18003
|
+
schedule,
|
|
18004
|
+
drawId,
|
|
18005
|
+
score
|
|
18006
|
+
});
|
|
18007
|
+
}
|
|
18008
|
+
};
|
|
18009
|
+
const addPartner = ({ participant, partnerParticipantId }) => {
|
|
18010
|
+
const addPartnerParticiapntId = (element, partnerParticipantId2) => {
|
|
18011
|
+
if (element) {
|
|
18012
|
+
if (!element.partnerParticipantIds)
|
|
18013
|
+
element.partnerParticipantIds = [];
|
|
18014
|
+
if (!element.partnerParticipantIds.includes(partnerParticipantId2))
|
|
18015
|
+
element.partnerParticipantIds.push(partnerParticipantId2);
|
|
18016
|
+
}
|
|
18017
|
+
};
|
|
18018
|
+
if (withDraws)
|
|
18019
|
+
addPartnerParticiapntId(
|
|
18020
|
+
participant?.draws?.[drawId],
|
|
18021
|
+
partnerParticipantId
|
|
18353
18022
|
);
|
|
18354
|
-
|
|
18355
|
-
|
|
18356
|
-
|
|
18357
|
-
|
|
18358
|
-
})
|
|
18023
|
+
if (withEvents) {
|
|
18024
|
+
addPartnerParticiapntId(
|
|
18025
|
+
participant?.events?.[eventId],
|
|
18026
|
+
partnerParticipantId
|
|
18359
18027
|
);
|
|
18360
|
-
|
|
18361
|
-
|
|
18362
|
-
|
|
18363
|
-
|
|
18364
|
-
|
|
18365
|
-
|
|
18028
|
+
}
|
|
18029
|
+
if (withMatchUps) {
|
|
18030
|
+
addPartnerParticiapntId(
|
|
18031
|
+
participant?.matchUps?.[matchUpId],
|
|
18032
|
+
partnerParticipantId
|
|
18033
|
+
);
|
|
18034
|
+
}
|
|
18035
|
+
};
|
|
18036
|
+
if (participantId && participantMap[participantId]) {
|
|
18037
|
+
const opponentParticipantId = opponents?.[sideNumber];
|
|
18038
|
+
addMatchUp(participantId, opponentParticipantId);
|
|
18039
|
+
const isPair = participantMap[participantId]?.participant.participantType === PAIR;
|
|
18040
|
+
const individualParticipantIds = participantMap[participantId]?.participant.individualParticipantIds || [];
|
|
18041
|
+
if (matchUpTieId) {
|
|
18042
|
+
if (withTeamMatchUps) {
|
|
18043
|
+
const addTeamMatchUp = (participantId2) => participantMap[participantId2].matchUps[matchUpTieId] = {
|
|
18044
|
+
participantWon: tieWinningSide === sideNumber,
|
|
18045
|
+
matchUpType: TypeEnum.Team,
|
|
18046
|
+
matchUpId: matchUpTieId,
|
|
18047
|
+
sideNumber
|
|
18048
|
+
};
|
|
18049
|
+
addTeamMatchUp(participantId);
|
|
18050
|
+
individualParticipantIds.forEach(addTeamMatchUp);
|
|
18051
|
+
}
|
|
18052
|
+
if (withDraws && !participantMap[participantId].draws[drawId]) {
|
|
18053
|
+
const teamParticipantId = matchUpSides.find(
|
|
18054
|
+
(s) => s.sideNumber === sideNumber
|
|
18055
|
+
)?.participant?.participantId;
|
|
18056
|
+
const teamEntryStatus = participantMap[teamParticipantId]?.draws?.[drawId]?.entryStatus;
|
|
18057
|
+
const addDrawData = (participantId2) => participantMap[participantId2].draws[drawId] = {
|
|
18058
|
+
entryStatus: teamEntryStatus,
|
|
18059
|
+
// add positions played in lineUp collections
|
|
18366
18060
|
eventId,
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
loserTo,
|
|
18372
|
-
matchUpId,
|
|
18373
|
-
matchUpType,
|
|
18374
|
-
matchUpFormat,
|
|
18375
|
-
matchUpStatus,
|
|
18376
|
-
matchUpStatusCodes,
|
|
18377
|
-
matchUpTieId,
|
|
18378
|
-
opponentParticipantInfo,
|
|
18379
|
-
participantWon,
|
|
18380
|
-
partnerParticipantId,
|
|
18381
|
-
perspectiveScoreString: participantScore,
|
|
18382
|
-
processCodes,
|
|
18383
|
-
roundName,
|
|
18384
|
-
roundNumber,
|
|
18385
|
-
roundPosition,
|
|
18386
|
-
schedule,
|
|
18387
|
-
score,
|
|
18388
|
-
sides,
|
|
18389
|
-
stage,
|
|
18390
|
-
stageSequence,
|
|
18391
|
-
structureName,
|
|
18392
|
-
structureId,
|
|
18393
|
-
tieFormat,
|
|
18394
|
-
tournamentId,
|
|
18395
|
-
winnerTo,
|
|
18396
|
-
winningSide
|
|
18397
|
-
});
|
|
18398
|
-
if (partnerParticipantId) {
|
|
18399
|
-
participantIdMap[relevantParticipantId].events[eventId].partnerParticipantIds.push(partnerParticipantId);
|
|
18400
|
-
participantIdMap[relevantParticipantId].draws[drawId].partnerParticipantIds.push(partnerParticipantId);
|
|
18401
|
-
participantIdMap[relevantParticipantId].events[eventId].partnerParticipantId = partnerParticipantId;
|
|
18402
|
-
participantIdMap[relevantParticipantId].draws[drawId].partnerParticipantId = partnerParticipantId;
|
|
18061
|
+
drawId
|
|
18062
|
+
};
|
|
18063
|
+
addDrawData(participantId);
|
|
18064
|
+
individualParticipantIds.forEach(addDrawData);
|
|
18403
18065
|
}
|
|
18404
|
-
|
|
18066
|
+
}
|
|
18067
|
+
if (isPair) {
|
|
18068
|
+
individualParticipantIds.forEach(
|
|
18069
|
+
(participantId2) => participantMap[participantId2] && addMatchUp(participantId2, opponentParticipantId)
|
|
18070
|
+
);
|
|
18071
|
+
individualParticipantIds.forEach((participantId2, i) => {
|
|
18072
|
+
const partnerParticipantId = individualParticipantIds[1 - i];
|
|
18073
|
+
const participant = participantMap[participantId2];
|
|
18074
|
+
participant && addPartner({ participant, partnerParticipantId });
|
|
18075
|
+
});
|
|
18076
|
+
if (withEvents && matchUpSides) {
|
|
18077
|
+
const teamParticipantId = matchUpSides.find(
|
|
18078
|
+
(s) => s.sideNumber === sideNumber
|
|
18079
|
+
)?.participant?.participantId;
|
|
18080
|
+
if (teamParticipantId) {
|
|
18081
|
+
const teamEntry = participantMap[teamParticipantId]?.events[eventId];
|
|
18082
|
+
if (teamEntry) {
|
|
18083
|
+
participantMap[participantId].events[eventId] = { ...teamEntry };
|
|
18084
|
+
individualParticipantIds.forEach(
|
|
18085
|
+
(individualParticiapntId) => participantMap[individualParticiapntId].events[eventId] = {
|
|
18086
|
+
...teamEntry
|
|
18087
|
+
}
|
|
18088
|
+
);
|
|
18089
|
+
} else {
|
|
18090
|
+
console.log("Missing teamEntry", { eventId, teamParticipantId });
|
|
18091
|
+
}
|
|
18092
|
+
}
|
|
18093
|
+
}
|
|
18094
|
+
}
|
|
18095
|
+
if (winningSide) {
|
|
18096
|
+
const processParticipantId = (id) => {
|
|
18405
18097
|
if (participantWon) {
|
|
18406
|
-
|
|
18098
|
+
participantMap[id].counters[matchUpType].wins += 1;
|
|
18099
|
+
participantMap[id].counters.wins += 1;
|
|
18100
|
+
if (matchUpStatus === WALKOVER$1) {
|
|
18101
|
+
participantMap[id].counters[matchUpType].walkoverWins += 1;
|
|
18102
|
+
participantMap[id].counters.walkoverWins += 1;
|
|
18103
|
+
}
|
|
18104
|
+
if (matchUpStatus === DEFAULTED) {
|
|
18105
|
+
participantMap[id].counters[matchUpType].defaultWins += 1;
|
|
18106
|
+
participantMap[id].counters.defaultWins += 1;
|
|
18107
|
+
}
|
|
18407
18108
|
} else {
|
|
18408
|
-
|
|
18109
|
+
participantMap[id].counters[matchUpType].losses += 1;
|
|
18110
|
+
participantMap[id].counters.losses += 1;
|
|
18111
|
+
if (matchUpStatus === WALKOVER$1) {
|
|
18112
|
+
participantMap[id].counters[matchUpType].walkovers += 1;
|
|
18113
|
+
participantMap[id].counters.walkovers += 1;
|
|
18114
|
+
}
|
|
18115
|
+
if (matchUpStatus === DEFAULTED) {
|
|
18116
|
+
participantMap[id].counters[matchUpType].defaults += 1;
|
|
18117
|
+
participantMap[id].counters.defaults += 1;
|
|
18118
|
+
}
|
|
18409
18119
|
}
|
|
18410
|
-
}
|
|
18120
|
+
};
|
|
18121
|
+
processParticipantId(participantId);
|
|
18122
|
+
individualParticipantIds.forEach(processParticipantId);
|
|
18411
18123
|
}
|
|
18412
|
-
|
|
18413
|
-
});
|
|
18414
|
-
if (Array.isArray(matchUp.potentialParticipants)) {
|
|
18415
|
-
const potentialParticipantIds = getParticipantIds(
|
|
18416
|
-
matchUp.potentialParticipants.flat()
|
|
18417
|
-
);
|
|
18418
|
-
potentialParticipantIds?.forEach((participantId) => {
|
|
18419
|
-
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
18420
|
-
relevantParticipantIds?.forEach(({ relevantParticipantId }) => {
|
|
18421
|
-
participantIdMap[relevantParticipantId].potentialMatchUps[matchUpId] = definedAttributes({
|
|
18422
|
-
drawId,
|
|
18423
|
-
eventId,
|
|
18424
|
-
eventType,
|
|
18425
|
-
matchUpId,
|
|
18426
|
-
matchUpType,
|
|
18427
|
-
matchUpFormat,
|
|
18428
|
-
roundName,
|
|
18429
|
-
roundNumber,
|
|
18430
|
-
roundPosition,
|
|
18431
|
-
schedule,
|
|
18432
|
-
tieFormat,
|
|
18433
|
-
structureName,
|
|
18434
|
-
tournamentId,
|
|
18435
|
-
potential: true
|
|
18436
|
-
});
|
|
18437
|
-
});
|
|
18438
|
-
});
|
|
18124
|
+
}
|
|
18439
18125
|
}
|
|
18440
18126
|
}
|
|
18441
18127
|
|
|
18442
|
-
function
|
|
18443
|
-
const
|
|
18444
|
-
|
|
18445
|
-
|
|
18446
|
-
|
|
18447
|
-
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18451
|
-
|
|
18452
|
-
|
|
18453
|
-
|
|
18454
|
-
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
|
|
18458
|
-
|
|
18459
|
-
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
const { relevantParticipantIdsMap } = getRelevantParticipantIdsMap({
|
|
18467
|
-
processParticipantId: initializeParticipantId,
|
|
18468
|
-
tournamentRecord
|
|
18469
|
-
});
|
|
18128
|
+
function getParticipantEntries(params) {
|
|
18129
|
+
const {
|
|
18130
|
+
participantFilters,
|
|
18131
|
+
convertExtensions,
|
|
18132
|
+
policyDefinitions,
|
|
18133
|
+
tournamentRecord,
|
|
18134
|
+
usePublishState,
|
|
18135
|
+
contextProfile,
|
|
18136
|
+
participantMap,
|
|
18137
|
+
withPotentialMatchUps,
|
|
18138
|
+
withRankingProfile,
|
|
18139
|
+
withScheduleTimes,
|
|
18140
|
+
withScheduleItems,
|
|
18141
|
+
scheduleAnalysis,
|
|
18142
|
+
withTeamMatchUps,
|
|
18143
|
+
withStatistics,
|
|
18144
|
+
withOpponents,
|
|
18145
|
+
withMatchUps,
|
|
18146
|
+
withSeeding,
|
|
18147
|
+
withEvents,
|
|
18148
|
+
withDraws
|
|
18149
|
+
} = params;
|
|
18150
|
+
if (withScheduleItems)
|
|
18151
|
+
console.log({ withScheduleItems });
|
|
18470
18152
|
const targetParticipantIds = participantFilters?.participantIds;
|
|
18471
18153
|
const getRelevantParticipantIds = (participantId) => {
|
|
18472
|
-
const relevantParticipantIds =
|
|
18154
|
+
const relevantParticipantIds = [participantId];
|
|
18473
18155
|
relevantParticipantIds.push(participantId);
|
|
18156
|
+
participantMap[participantId]?.participant.individualParticipantIds?.forEach(
|
|
18157
|
+
(individualParticiapntId) => relevantParticipantIds.push(individualParticiapntId)
|
|
18158
|
+
);
|
|
18474
18159
|
return relevantParticipantIds.some(
|
|
18475
|
-
(obj) => !targetParticipantIds || targetParticipantIds.includes(obj.relevantParticipantId)
|
|
18160
|
+
(obj) => !targetParticipantIds?.length || targetParticipantIds.includes(obj.relevantParticipantId)
|
|
18476
18161
|
) ? relevantParticipantIds : [];
|
|
18477
18162
|
};
|
|
18478
|
-
|
|
18479
|
-
|
|
18480
|
-
|
|
18481
|
-
|
|
18482
|
-
|
|
18483
|
-
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
|
|
18487
|
-
|
|
18488
|
-
|
|
18489
|
-
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18493
|
-
|
|
18163
|
+
const withOpts = {
|
|
18164
|
+
withMatchUps: withMatchUps || withRankingProfile,
|
|
18165
|
+
withEvents: withEvents || withRankingProfile,
|
|
18166
|
+
withDraws: withDraws || withRankingProfile,
|
|
18167
|
+
withPotentialMatchUps,
|
|
18168
|
+
withRankingProfile,
|
|
18169
|
+
withScheduleTimes,
|
|
18170
|
+
scheduleAnalysis,
|
|
18171
|
+
withTeamMatchUps,
|
|
18172
|
+
withStatistics,
|
|
18173
|
+
participantMap,
|
|
18174
|
+
withOpponents,
|
|
18175
|
+
withSeeding
|
|
18176
|
+
};
|
|
18177
|
+
const participantIdsWithConflicts = [];
|
|
18178
|
+
const mappedMatchUps = {};
|
|
18179
|
+
const matchUps = [];
|
|
18180
|
+
const eventsPublishStatuses = {};
|
|
18181
|
+
const derivedEventInfo = {};
|
|
18182
|
+
const derivedDrawInfo = {};
|
|
18183
|
+
const getRanking = ({ eventType, scaleNames, participantId }) => participantMap[participantId].participant?.rankings?.[eventType]?.find(
|
|
18184
|
+
(ranking) => scaleNames.includes(ranking.scaleName)
|
|
18185
|
+
)?.scaleValue;
|
|
18186
|
+
for (const event of tournamentRecord?.events || []) {
|
|
18187
|
+
if (participantFilters?.eventIds && !participantFilters.eventIds.includes(event.eventId))
|
|
18188
|
+
continue;
|
|
18189
|
+
const {
|
|
18190
|
+
drawDefinitions = [],
|
|
18191
|
+
extensions = [],
|
|
18192
|
+
eventType,
|
|
18193
|
+
eventName,
|
|
18194
|
+
category,
|
|
18195
|
+
entries,
|
|
18196
|
+
eventId,
|
|
18197
|
+
gender
|
|
18198
|
+
} = event;
|
|
18199
|
+
const { flightProfile } = getFlightProfile({ event });
|
|
18200
|
+
const flights = flightProfile?.flights ?? [];
|
|
18201
|
+
const publishStatuses = getEventPublishStatuses({ event });
|
|
18202
|
+
const publishedSeeding = publishStatuses?.publishedSeeding;
|
|
18203
|
+
if (publishStatuses)
|
|
18204
|
+
eventsPublishStatuses[eventId] = publishStatuses;
|
|
18205
|
+
if (withEvents || withSeeding || withRankingProfile) {
|
|
18206
|
+
const extensionConversions = convertExtensions ? Object.assign({}, ...extensionsToAttributes(extensions)) : {};
|
|
18207
|
+
derivedEventInfo[eventId] = {
|
|
18208
|
+
...extensionConversions,
|
|
18209
|
+
eventName,
|
|
18210
|
+
eventType,
|
|
18211
|
+
category,
|
|
18212
|
+
eventId,
|
|
18213
|
+
gender
|
|
18214
|
+
};
|
|
18215
|
+
const scaleNames = [
|
|
18216
|
+
category?.categoryName,
|
|
18217
|
+
category?.ageCategoryCode
|
|
18218
|
+
].filter(Boolean);
|
|
18219
|
+
for (const entry of entries) {
|
|
18220
|
+
const { participantId } = entry;
|
|
18221
|
+
if (!participantId || !participantMap[participantId])
|
|
18222
|
+
continue;
|
|
18223
|
+
const ranking = getRanking({ eventType, scaleNames, participantId });
|
|
18224
|
+
let seedAssignments, seedValue;
|
|
18225
|
+
if (withSeeding) {
|
|
18226
|
+
const participant = participantMap[participantId].participant;
|
|
18227
|
+
({ seedAssignments, seedValue } = getEventSeedAssignments({
|
|
18228
|
+
publishedSeeding,
|
|
18229
|
+
usePublishState,
|
|
18230
|
+
withSeeding,
|
|
18231
|
+
participant,
|
|
18232
|
+
event
|
|
18233
|
+
}));
|
|
18494
18234
|
}
|
|
18495
|
-
|
|
18235
|
+
const addEventEntry = (id) => {
|
|
18236
|
+
if (participantMap[id]?.events?.[eventId])
|
|
18237
|
+
return;
|
|
18238
|
+
const participant = participantMap[id];
|
|
18239
|
+
processEventEntry({
|
|
18240
|
+
extensionConversions,
|
|
18241
|
+
seedAssignments,
|
|
18242
|
+
participant,
|
|
18243
|
+
withSeeding,
|
|
18244
|
+
seedValue,
|
|
18245
|
+
eventId,
|
|
18246
|
+
ranking,
|
|
18247
|
+
entry
|
|
18248
|
+
});
|
|
18249
|
+
};
|
|
18250
|
+
addEventEntry(participantId);
|
|
18251
|
+
const individualParticipantIds = participantMap[participantId].participant.individualParticipantIds || [];
|
|
18252
|
+
individualParticipantIds.forEach(addEventEntry);
|
|
18253
|
+
}
|
|
18496
18254
|
}
|
|
18497
|
-
|
|
18498
|
-
|
|
18499
|
-
|
|
18500
|
-
|
|
18501
|
-
|
|
18502
|
-
|
|
18503
|
-
|
|
18504
|
-
|
|
18505
|
-
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
|
|
18255
|
+
const eventPublishedSeeding = eventsPublishStatuses?.[eventId]?.publishedSeeding;
|
|
18256
|
+
if (withDraws || withRankingProfile || withSeeding) {
|
|
18257
|
+
const getSeedingMap = (assignments) => assignments ? Object.assign(
|
|
18258
|
+
{},
|
|
18259
|
+
...assignments.map(
|
|
18260
|
+
({ participantId, seedValue, seedNumber }) => ({
|
|
18261
|
+
[participantId]: { seedValue, seedNumber }
|
|
18262
|
+
})
|
|
18263
|
+
)
|
|
18264
|
+
) : void 0;
|
|
18265
|
+
const drawIds = unique([
|
|
18266
|
+
...drawDefinitions.map(extractAttributes("drawId")),
|
|
18267
|
+
...flights.map(extractAttributes("drawId"))
|
|
18268
|
+
]);
|
|
18269
|
+
for (const drawId of drawIds) {
|
|
18270
|
+
const drawDefinition = drawDefinitions.find(
|
|
18271
|
+
(drawDefinition2) => drawDefinition2.drawId === drawId
|
|
18272
|
+
);
|
|
18273
|
+
const flight = flights?.find((flight2) => flight2.drawId === drawId);
|
|
18274
|
+
const entries2 = drawDefinition?.entries || flight?.drawEntries;
|
|
18275
|
+
const {
|
|
18276
|
+
structures = [],
|
|
18277
|
+
drawOrder,
|
|
18278
|
+
drawName,
|
|
18279
|
+
drawType
|
|
18280
|
+
} = drawDefinition ?? {};
|
|
18281
|
+
const flightNumber = flight?.flightNumber;
|
|
18282
|
+
const scaleNames = [
|
|
18283
|
+
category?.categoryName,
|
|
18284
|
+
category?.ageCategoryCode
|
|
18285
|
+
].filter(Boolean);
|
|
18286
|
+
const orderedStructureIds = (drawDefinition?.structures || []).sort((a, b) => structureSort(a, b)).map(({ structureId, structures: structures2 }) => {
|
|
18287
|
+
return [
|
|
18288
|
+
structureId,
|
|
18289
|
+
...(structures2 || []).map(({ structureId: structureId2 }) => structureId2)
|
|
18290
|
+
];
|
|
18291
|
+
}).flat(Infinity);
|
|
18292
|
+
let qualifyingPositionAssignments, qualifyingSeedAssignments, mainPositionAssignments, mainSeedAssignments, drawSize = 0;
|
|
18293
|
+
const assignedParticipantIds = structures.filter(
|
|
18294
|
+
({ stage, stageSequence }) => stage === MAIN && stageSequence === 1 || stage === QUALIFYING
|
|
18295
|
+
).flatMap((structure) => {
|
|
18296
|
+
const { seedAssignments, stageSequence, stage } = structure;
|
|
18297
|
+
const { positionAssignments } = getPositionAssignments({
|
|
18298
|
+
structure
|
|
18299
|
+
});
|
|
18300
|
+
if (stage === MAIN) {
|
|
18301
|
+
drawSize = positionAssignments?.length ?? 0;
|
|
18302
|
+
mainPositionAssignments = positionAssignments;
|
|
18303
|
+
mainSeedAssignments = seedAssignments;
|
|
18304
|
+
} else if (stageSequence === 1) {
|
|
18305
|
+
qualifyingPositionAssignments = positionAssignments;
|
|
18306
|
+
qualifyingSeedAssignments = seedAssignments;
|
|
18307
|
+
}
|
|
18308
|
+
return positionAssignments;
|
|
18309
|
+
}).map(({ participantId }) => participantId).filter(Boolean);
|
|
18310
|
+
const mainSeedingMap = getSeedingMap(mainSeedAssignments);
|
|
18311
|
+
const qualifyingSeedingMap = getSeedingMap(qualifyingSeedAssignments);
|
|
18312
|
+
const relevantEntries = !drawDefinition ? entries2 : entries2.filter(
|
|
18313
|
+
({ participantId }) => assignedParticipantIds.includes(participantId)
|
|
18314
|
+
);
|
|
18315
|
+
const seedingPublished = !usePublishState || eventPublishedSeeding?.published && (eventPublishedSeeding?.drawIds?.length === 0 || eventPublishedSeeding?.drawIds?.includes(drawId));
|
|
18316
|
+
for (const entry of relevantEntries) {
|
|
18317
|
+
const { entryStatus, entryStage, entryPosition, participantId } = entry;
|
|
18318
|
+
const ranking = getRanking({
|
|
18319
|
+
participantId,
|
|
18320
|
+
scaleNames,
|
|
18321
|
+
eventType
|
|
18512
18322
|
});
|
|
18323
|
+
const addDrawEntry = (id) => {
|
|
18324
|
+
if (participantMap[id].draws?.[drawId])
|
|
18325
|
+
return;
|
|
18326
|
+
const includeSeeding = withSeeding && seedingPublished;
|
|
18327
|
+
const seedAssignments = includeSeeding ? {} : void 0;
|
|
18328
|
+
const mainSeeding = includeSeeding ? mainSeedingMap?.[participantId]?.seedValue || mainSeedingMap?.[participantId]?.seedNumber : void 0;
|
|
18329
|
+
const mainSeedingAssignments = mainSeeding ? mainSeedingMap?.[participantId] : void 0;
|
|
18330
|
+
const qualifyingSeeding = includeSeeding ? qualifyingSeedingMap?.[participantId]?.seedValue || qualifyingSeedingMap?.[participantId]?.seedNumber : void 0;
|
|
18331
|
+
const qualifyingSeedingAssignments = qualifyingSeeding ? qualifyingSeedingMap?.[participantId] : void 0;
|
|
18332
|
+
if (seedAssignments && mainSeeding)
|
|
18333
|
+
seedAssignments[MAIN] = mainSeedingAssignments;
|
|
18334
|
+
if (seedAssignments && qualifyingSeeding)
|
|
18335
|
+
seedAssignments[QUALIFYING] = qualifyingSeedingAssignments;
|
|
18336
|
+
const seedValue = mainSeeding || qualifyingSeeding;
|
|
18337
|
+
if (seedValue) {
|
|
18338
|
+
if (!participantMap[id].participant.seedings[eventType])
|
|
18339
|
+
participantMap[id].participant.seedings[eventType] = [];
|
|
18340
|
+
if (mainSeedingAssignments) {
|
|
18341
|
+
participantMap[id].participant.seedings[eventType].push({
|
|
18342
|
+
...mainSeedingAssignments,
|
|
18343
|
+
scaleName: drawId
|
|
18344
|
+
});
|
|
18345
|
+
}
|
|
18346
|
+
if (qualifyingSeedingAssignments) {
|
|
18347
|
+
participantMap[id].participant.seedings[eventType].push({
|
|
18348
|
+
...qualifyingSeedingAssignments,
|
|
18349
|
+
scaleName: drawId
|
|
18350
|
+
});
|
|
18351
|
+
}
|
|
18352
|
+
if (seedAssignments) {
|
|
18353
|
+
if (!participantMap[id].events[eventId].seedAssignments)
|
|
18354
|
+
participantMap[id].events[eventId].seedAssignments = {};
|
|
18355
|
+
Object.keys(seedAssignments).forEach(
|
|
18356
|
+
(stage) => participantMap[id].events[eventId].seedAssignments[stage] = seedAssignments[stage]
|
|
18357
|
+
);
|
|
18358
|
+
}
|
|
18359
|
+
}
|
|
18360
|
+
if ((withEvents || withRankingProfile) && participantMap[id] && eventId) {
|
|
18361
|
+
if (!participantMap[id].events[eventId])
|
|
18362
|
+
participantMap[id].events[eventId] = {};
|
|
18363
|
+
if (includeSeeding) {
|
|
18364
|
+
participantMap[id].events[eventId].seedValue = seedValue;
|
|
18365
|
+
} else if (participantMap[id].events[eventId].seedValue) {
|
|
18366
|
+
participantMap[id].events[eventId].seedValue = void 0;
|
|
18367
|
+
}
|
|
18368
|
+
}
|
|
18369
|
+
if (withDraws || withRankingProfile) {
|
|
18370
|
+
participantMap[id].draws[drawId] = definedAttributes(
|
|
18371
|
+
{
|
|
18372
|
+
seedAssignments,
|
|
18373
|
+
entryPosition,
|
|
18374
|
+
entryStatus,
|
|
18375
|
+
entryStage,
|
|
18376
|
+
eventId,
|
|
18377
|
+
ranking,
|
|
18378
|
+
drawId
|
|
18379
|
+
},
|
|
18380
|
+
false,
|
|
18381
|
+
false,
|
|
18382
|
+
true
|
|
18383
|
+
);
|
|
18384
|
+
}
|
|
18385
|
+
};
|
|
18386
|
+
if (![UNGROUPED, UNPAIRED].includes(entryStatus)) {
|
|
18387
|
+
addDrawEntry(participantId);
|
|
18388
|
+
const individualParticipantIds = participantMap[participantId].participant.individualParticipantIds || [];
|
|
18389
|
+
individualParticipantIds?.forEach(addDrawEntry);
|
|
18390
|
+
}
|
|
18513
18391
|
}
|
|
18514
|
-
|
|
18392
|
+
derivedDrawInfo[drawId] = {
|
|
18393
|
+
qualifyingPositionAssignments,
|
|
18394
|
+
qualifyingSeedAssignments,
|
|
18395
|
+
mainPositionAssignments,
|
|
18396
|
+
qualifyingSeedingMap,
|
|
18397
|
+
mainSeedAssignments,
|
|
18398
|
+
orderedStructureIds,
|
|
18399
|
+
mainSeedingMap,
|
|
18400
|
+
flightNumber,
|
|
18401
|
+
drawOrder,
|
|
18402
|
+
drawName,
|
|
18403
|
+
drawType,
|
|
18404
|
+
drawSize,
|
|
18405
|
+
drawId
|
|
18406
|
+
// qualifyingDrawSize,
|
|
18407
|
+
};
|
|
18408
|
+
}
|
|
18515
18409
|
}
|
|
18516
|
-
if (
|
|
18517
|
-
const
|
|
18518
|
-
|
|
18519
|
-
|
|
18520
|
-
|
|
18521
|
-
|
|
18522
|
-
|
|
18523
|
-
|
|
18524
|
-
|
|
18410
|
+
if (withRankingProfile || scheduleAnalysis || withTeamMatchUps || withStatistics || withOpponents || withMatchUps || withDraws) {
|
|
18411
|
+
const nextMatchUps = !!scheduleAnalysis || withPotentialMatchUps;
|
|
18412
|
+
const eventMatchUps = allEventMatchUps({
|
|
18413
|
+
afterRecoveryTimes: !!scheduleAnalysis,
|
|
18414
|
+
policyDefinitions,
|
|
18415
|
+
tournamentRecord,
|
|
18416
|
+
inContext: true,
|
|
18417
|
+
contextProfile,
|
|
18418
|
+
participantMap,
|
|
18419
|
+
nextMatchUps,
|
|
18420
|
+
event
|
|
18421
|
+
})?.matchUps ?? [];
|
|
18422
|
+
for (const matchUp of eventMatchUps) {
|
|
18423
|
+
const {
|
|
18424
|
+
finishingPositionRange,
|
|
18425
|
+
potentialParticipants,
|
|
18426
|
+
tieMatchUps = [],
|
|
18427
|
+
sides = [],
|
|
18428
|
+
winningSide,
|
|
18429
|
+
matchUpType,
|
|
18430
|
+
matchUpId,
|
|
18431
|
+
eventId: eventId2,
|
|
18432
|
+
drawId,
|
|
18433
|
+
collectionId,
|
|
18434
|
+
stageSequence,
|
|
18435
|
+
finishingRound,
|
|
18436
|
+
matchUpStatus,
|
|
18437
|
+
roundPosition,
|
|
18438
|
+
roundNumber,
|
|
18439
|
+
structureId,
|
|
18440
|
+
schedule,
|
|
18441
|
+
score,
|
|
18442
|
+
stage
|
|
18443
|
+
} = matchUp;
|
|
18444
|
+
mappedMatchUps[matchUpId] = matchUp;
|
|
18445
|
+
const baseAttrs = {
|
|
18446
|
+
finishingPositionRange,
|
|
18447
|
+
finishingRound,
|
|
18448
|
+
stageSequence,
|
|
18449
|
+
roundPosition,
|
|
18450
|
+
collectionId,
|
|
18451
|
+
roundNumber,
|
|
18452
|
+
structureId,
|
|
18453
|
+
schedule,
|
|
18454
|
+
eventId: eventId2,
|
|
18455
|
+
drawId,
|
|
18456
|
+
score,
|
|
18457
|
+
stage
|
|
18458
|
+
};
|
|
18459
|
+
processSides({
|
|
18460
|
+
...baseAttrs,
|
|
18461
|
+
...withOpts,
|
|
18462
|
+
matchUpStatus,
|
|
18463
|
+
winningSide,
|
|
18464
|
+
matchUpType,
|
|
18465
|
+
matchUpId,
|
|
18466
|
+
sides
|
|
18467
|
+
});
|
|
18468
|
+
for (const tieMatchUp of tieMatchUps) {
|
|
18469
|
+
const {
|
|
18470
|
+
winningSide: tieMatchUpWinningSide,
|
|
18471
|
+
sides: tieMatchUpSides = [],
|
|
18472
|
+
matchUpId: tieMatchUpId,
|
|
18473
|
+
matchUpStatus: matchUpStatus2,
|
|
18474
|
+
matchUpType: matchUpType2
|
|
18475
|
+
} = tieMatchUp;
|
|
18476
|
+
processSides({
|
|
18477
|
+
...baseAttrs,
|
|
18478
|
+
...withOpts,
|
|
18479
|
+
winningSide: tieMatchUpWinningSide,
|
|
18480
|
+
tieWinningSide: winningSide,
|
|
18481
|
+
matchUpTieId: matchUpId,
|
|
18482
|
+
matchUpId: tieMatchUpId,
|
|
18483
|
+
sides: tieMatchUpSides,
|
|
18484
|
+
matchUpSides: sides,
|
|
18485
|
+
matchUpStatus: matchUpStatus2,
|
|
18486
|
+
matchUpType: matchUpType2
|
|
18487
|
+
});
|
|
18525
18488
|
}
|
|
18526
|
-
|
|
18527
|
-
|
|
18528
|
-
|
|
18529
|
-
|
|
18530
|
-
|
|
18531
|
-
|
|
18532
|
-
|
|
18533
|
-
|
|
18534
|
-
|
|
18535
|
-
|
|
18536
|
-
|
|
18537
|
-
|
|
18538
|
-
|
|
18539
|
-
|
|
18540
|
-
|
|
18541
|
-
|
|
18542
|
-
|
|
18489
|
+
if (Array.isArray(potentialParticipants) && (nextMatchUps || !!scheduleAnalysis || withScheduleTimes)) {
|
|
18490
|
+
const potentialParticipantIds = potentialParticipants.flat().map(extractAttributes("participantId")).filter(Boolean);
|
|
18491
|
+
potentialParticipantIds?.forEach((participantId) => {
|
|
18492
|
+
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
18493
|
+
relevantParticipantIds?.forEach((relevantParticipantId) => {
|
|
18494
|
+
if (!participantMap[relevantParticipantId]) {
|
|
18495
|
+
return;
|
|
18496
|
+
}
|
|
18497
|
+
participantMap[relevantParticipantId].potentialMatchUps[matchUpId] = definedAttributes({
|
|
18498
|
+
tournamentId: tournamentRecord?.tournamentId,
|
|
18499
|
+
matchUpId,
|
|
18500
|
+
eventId: eventId2,
|
|
18501
|
+
drawId
|
|
18502
|
+
});
|
|
18503
|
+
});
|
|
18504
|
+
if (!!scheduleAnalysis || withScheduleTimes) {
|
|
18505
|
+
addScheduleItem({
|
|
18506
|
+
potential: true,
|
|
18507
|
+
participantMap,
|
|
18508
|
+
participantId,
|
|
18509
|
+
matchUpStatus,
|
|
18510
|
+
roundPosition,
|
|
18511
|
+
structureId,
|
|
18512
|
+
matchUpType,
|
|
18513
|
+
roundNumber,
|
|
18514
|
+
matchUpId,
|
|
18515
|
+
schedule,
|
|
18516
|
+
drawId,
|
|
18517
|
+
score
|
|
18518
|
+
});
|
|
18519
|
+
}
|
|
18543
18520
|
});
|
|
18544
|
-
if (extension)
|
|
18545
|
-
drawDefinition.extensions = [extension];
|
|
18546
18521
|
}
|
|
18547
|
-
}
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
18551
|
-
|
|
18552
|
-
|
|
18553
|
-
|
|
18554
|
-
const
|
|
18555
|
-
|
|
18556
|
-
|
|
18557
|
-
|
|
18558
|
-
|
|
18559
|
-
}
|
|
18560
|
-
|
|
18561
|
-
const
|
|
18562
|
-
const
|
|
18563
|
-
|
|
18564
|
-
|
|
18565
|
-
|
|
18566
|
-
|
|
18567
|
-
|
|
18568
|
-
|
|
18569
|
-
if (seeding)
|
|
18570
|
-
Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
|
|
18571
|
-
eventsPublishStatuses[eventId] = {
|
|
18572
|
-
publishedDrawIds,
|
|
18573
|
-
publishedSeeding
|
|
18522
|
+
}
|
|
18523
|
+
matchUps.push(...eventMatchUps);
|
|
18524
|
+
}
|
|
18525
|
+
}
|
|
18526
|
+
if (withStatistics || withRankingProfile || !!scheduleAnalysis) {
|
|
18527
|
+
const aggregators = Object.values(participantMap);
|
|
18528
|
+
for (const participantAggregator of aggregators) {
|
|
18529
|
+
const {
|
|
18530
|
+
wins,
|
|
18531
|
+
losses,
|
|
18532
|
+
[SINGLES$1]: { wins: singlesWins, losses: singlesLosses },
|
|
18533
|
+
[DOUBLES$1]: { wins: doublesWins, losses: doublesLosses }
|
|
18534
|
+
} = participantAggregator.counters;
|
|
18535
|
+
const addStatValue = (statCode, wins2, losses2) => {
|
|
18536
|
+
const denominator = wins2 + losses2;
|
|
18537
|
+
const numerator = wins2;
|
|
18538
|
+
const statValue = denominator && numerator / denominator;
|
|
18539
|
+
participantAggregator.statistics[statCode] = {
|
|
18540
|
+
denominator,
|
|
18541
|
+
numerator,
|
|
18542
|
+
statValue,
|
|
18543
|
+
statCode
|
|
18574
18544
|
};
|
|
18545
|
+
};
|
|
18546
|
+
if (withStatistics) {
|
|
18547
|
+
addStatValue(WIN_RATIO$1, wins, losses);
|
|
18548
|
+
addStatValue(`${WIN_RATIO$1}.${SINGLES$1}`, singlesWins, singlesLosses);
|
|
18549
|
+
addStatValue(`${WIN_RATIO$1}.${DOUBLES$1}`, doublesWins, doublesLosses);
|
|
18575
18550
|
}
|
|
18576
|
-
|
|
18577
|
-
|
|
18578
|
-
|
|
18579
|
-
|
|
18580
|
-
|
|
18581
|
-
|
|
18582
|
-
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
18606
|
-
relevantParticipantIds?.forEach(({ relevantParticipantId }) => {
|
|
18607
|
-
if (!participantIdMap[relevantParticipantId].events[eventId]) {
|
|
18608
|
-
participantIdMap[relevantParticipantId].events[eventId] = {
|
|
18609
|
-
...filteredEventInfo,
|
|
18610
|
-
partnerParticipantIds: [],
|
|
18611
|
-
entryPosition,
|
|
18612
|
-
entryStatus,
|
|
18613
|
-
entryStage,
|
|
18614
|
-
drawIds: [],
|
|
18615
|
-
eventId
|
|
18616
|
-
};
|
|
18617
|
-
}
|
|
18618
|
-
if (!participantIdMap[relevantParticipantId].draws[drawId]) {
|
|
18619
|
-
const positionAssignments = getDerivedPositionAssignments({
|
|
18620
|
-
participantId: relevantParticipantId,
|
|
18621
|
-
derivedDrawInfo,
|
|
18622
|
-
drawId
|
|
18623
|
-
});
|
|
18624
|
-
const seedAssignments = getDerivedSeedAssignments({
|
|
18625
|
-
participantId: relevantParticipantId,
|
|
18626
|
-
derivedDrawInfo,
|
|
18627
|
-
drawId
|
|
18628
|
-
});
|
|
18629
|
-
participantIdMap[relevantParticipantId].draws[drawId] = definedAttributes({
|
|
18630
|
-
qualifyingDrawSize: derivedDrawInfo[drawId]?.qualifyingDrawSize,
|
|
18631
|
-
drawSize: derivedDrawInfo[drawId]?.drawSize,
|
|
18632
|
-
partnerParticipantIds: [],
|
|
18633
|
-
positionAssignments,
|
|
18634
|
-
eventDrawsCount,
|
|
18635
|
-
seedAssignments,
|
|
18636
|
-
entryPosition,
|
|
18637
|
-
entryStatus,
|
|
18638
|
-
entryStage,
|
|
18639
|
-
eventId,
|
|
18640
|
-
drawId
|
|
18641
|
-
});
|
|
18642
|
-
}
|
|
18643
|
-
const eventDrawIds = participantIdMap[relevantParticipantId].events[eventId].drawIds;
|
|
18644
|
-
if (eventDrawIds && !eventDrawIds?.includes(drawId)) {
|
|
18645
|
-
participantIdMap[relevantParticipantId].events[eventId].drawIds.push(drawId);
|
|
18551
|
+
if (withRankingProfile) {
|
|
18552
|
+
const diff = (range = []) => Math.abs(range[0] - range[1]);
|
|
18553
|
+
for (const drawId of Object.keys(participantAggregator.draws)) {
|
|
18554
|
+
const { orderedStructureIds = [], flightNumber } = derivedDrawInfo[drawId] || {};
|
|
18555
|
+
if (participantAggregator.structureParticipation && orderedStructureIds.length) {
|
|
18556
|
+
let finishingPositionRange;
|
|
18557
|
+
let nonQualifyingOrder = 0;
|
|
18558
|
+
const orderedParticipation = orderedStructureIds.map((structureId) => {
|
|
18559
|
+
const participation = participantAggregator.structureParticipation[structureId];
|
|
18560
|
+
if (!participation)
|
|
18561
|
+
return;
|
|
18562
|
+
if (!finishingPositionRange)
|
|
18563
|
+
finishingPositionRange = participation?.finishingPositionRange;
|
|
18564
|
+
if (diff(finishingPositionRange) > diff(participation?.finishingPositionRange))
|
|
18565
|
+
finishingPositionRange = participation?.finishingPositionRange;
|
|
18566
|
+
const notQualifying = participation.stage !== QUALIFYING;
|
|
18567
|
+
if (notQualifying)
|
|
18568
|
+
nonQualifyingOrder += 1;
|
|
18569
|
+
const participationOrder = notQualifying ? nonQualifyingOrder : void 0;
|
|
18570
|
+
return definedAttributes({
|
|
18571
|
+
...participation,
|
|
18572
|
+
participationOrder,
|
|
18573
|
+
flightNumber
|
|
18574
|
+
});
|
|
18575
|
+
}).filter(Boolean);
|
|
18576
|
+
if (participantAggregator.draws[drawId]) {
|
|
18577
|
+
participantAggregator.draws[drawId].finishingPositionRange = finishingPositionRange;
|
|
18578
|
+
participantAggregator.draws[drawId].structureParticipation = orderedParticipation;
|
|
18579
|
+
}
|
|
18646
18580
|
}
|
|
18647
|
-
});
|
|
18648
|
-
};
|
|
18649
|
-
const drawIdsWithDefinitions = event.drawDefinitions?.map(({ drawId }) => drawId) || [];
|
|
18650
|
-
eventInfo._flightProfile?.flights?.forEach((flight) => {
|
|
18651
|
-
const { drawId, drawEntries } = flight;
|
|
18652
|
-
if (!drawIdsWithDefinitions.includes(drawId)) {
|
|
18653
|
-
drawEntries?.forEach(
|
|
18654
|
-
(drawEntry) => addDrawData({ drawEntry, drawId })
|
|
18655
|
-
);
|
|
18656
18581
|
}
|
|
18657
|
-
});
|
|
18658
|
-
const { drawDetails, derivedInfo } = getDrawDetails({
|
|
18659
|
-
eventEntries,
|
|
18660
|
-
event
|
|
18661
|
-
});
|
|
18662
|
-
Object.assign(derivedDrawInfo, derivedInfo);
|
|
18663
|
-
if (event.eventType === TEAM$2 || // for TEAM events some individual attributes can only be derived by processing
|
|
18664
|
-
params.withScheduleItems || params.scheduleAnalysis || params.withStatistics || params.withOpponents || params.withMatchUps || params.withDraws) {
|
|
18665
|
-
const matchUps = allEventMatchUps({
|
|
18666
|
-
afterRecoveryTimes: params.scheduleAnalysis,
|
|
18667
|
-
participants: allTournamentParticipants,
|
|
18668
|
-
nextMatchUps: true,
|
|
18669
|
-
tournamentRecord,
|
|
18670
|
-
inContext: true,
|
|
18671
|
-
event
|
|
18672
|
-
})?.matchUps;
|
|
18673
|
-
matchUps?.forEach(
|
|
18674
|
-
(matchUp) => processMatchUp({
|
|
18675
|
-
relevantParticipantIdsMap,
|
|
18676
|
-
participantFilters,
|
|
18677
|
-
participantIdMap,
|
|
18678
|
-
derivedDrawInfo,
|
|
18679
|
-
eventDrawsCount,
|
|
18680
|
-
drawDetails,
|
|
18681
|
-
eventType,
|
|
18682
|
-
matchUp
|
|
18683
|
-
})
|
|
18684
|
-
);
|
|
18685
18582
|
}
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
|
|
18692
|
-
|
|
18693
|
-
|
|
18694
|
-
|
|
18695
|
-
|
|
18696
|
-
|
|
18697
|
-
|
|
18698
|
-
|
|
18699
|
-
|
|
18700
|
-
|
|
18701
|
-
|
|
18702
|
-
|
|
18703
|
-
|
|
18704
|
-
|
|
18705
|
-
|
|
18706
|
-
|
|
18707
|
-
|
|
18708
|
-
|
|
18709
|
-
|
|
18583
|
+
if (scheduleAnalysis) {
|
|
18584
|
+
const scheduledMinutesDifference = isObject(scheduleAnalysis) ? scheduleAnalysis.scheduledMinutesDifference : 0;
|
|
18585
|
+
const scheduleItems = participantAggregator.scheduleItems || [];
|
|
18586
|
+
const potentialMatchUps = participantAggregator.potentialMatchUps || {};
|
|
18587
|
+
const dateItems = scheduleItems.reduce((dateItems2, scheduleItem) => {
|
|
18588
|
+
const { scheduledDate, scheduledTime } = scheduleItem;
|
|
18589
|
+
if (!dateItems2[scheduledDate])
|
|
18590
|
+
dateItems2[scheduledDate] = [];
|
|
18591
|
+
if (scheduledTime)
|
|
18592
|
+
dateItems2[scheduledDate].push(scheduleItem);
|
|
18593
|
+
return dateItems2;
|
|
18594
|
+
}, {});
|
|
18595
|
+
Object.values(dateItems).forEach((items) => items.sort(timeSort));
|
|
18596
|
+
for (const scheduleItem of scheduleItems) {
|
|
18597
|
+
const {
|
|
18598
|
+
typeChangeTimeAfterRecovery,
|
|
18599
|
+
timeAfterRecovery,
|
|
18600
|
+
scheduledDate,
|
|
18601
|
+
scheduledTime
|
|
18602
|
+
} = scheduleItem;
|
|
18603
|
+
const scheduleItemsToConsider = dateItems[scheduledDate];
|
|
18604
|
+
const scheduledMinutes = timeStringMinutes(scheduledTime);
|
|
18605
|
+
for (const consideredItem of scheduleItemsToConsider) {
|
|
18606
|
+
const ignoreItem = consideredItem.matchUpId === scheduleItem.matchUpId || [WALKOVER$1, DEFAULTED].includes(consideredItem.matchUpStatus) && !consideredItem.scoreHasValue;
|
|
18607
|
+
if (ignoreItem)
|
|
18608
|
+
continue;
|
|
18609
|
+
const typeChange = scheduleItem.matchUpType !== consideredItem.matchUpType;
|
|
18610
|
+
const notBeforeTime = typeChange ? typeChangeTimeAfterRecovery || timeAfterRecovery : timeAfterRecovery;
|
|
18611
|
+
const sameDraw = scheduleItem.drawId === consideredItem.drawId;
|
|
18612
|
+
const bothPotential = potentialMatchUps[scheduleItem.matchUpId] && potentialMatchUps[consideredItem.matchUpId];
|
|
18613
|
+
const nextMinutes = timeStringMinutes(consideredItem.scheduledTime);
|
|
18614
|
+
const minutesDifference = Math.abs(nextMinutes - scheduledMinutes);
|
|
18615
|
+
const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : timeStringMinutes(notBeforeTime) > timeStringMinutes(consideredItem.scheduledTime);
|
|
18616
|
+
if (timeOverlap && !(bothPotential && sameDraw)) {
|
|
18617
|
+
participantAggregator.scheduleConflicts.push({
|
|
18618
|
+
priorScheduledMatchUpId: consideredItem.matchUpId,
|
|
18619
|
+
matchUpIdWithConflict: scheduleItem.matchUpId
|
|
18620
|
+
});
|
|
18621
|
+
}
|
|
18622
|
+
}
|
|
18623
|
+
}
|
|
18624
|
+
const pid = participantAggregator.participant.participantId;
|
|
18625
|
+
if (participantAggregator.scheduleConflicts.length) {
|
|
18626
|
+
participantIdsWithConflicts.push(pid);
|
|
18627
|
+
}
|
|
18628
|
+
participantMap[pid].scheduleConflicts = participantAggregator.scheduleConflicts;
|
|
18710
18629
|
}
|
|
18711
18630
|
}
|
|
18712
|
-
|
|
18713
|
-
|
|
18714
|
-
|
|
18715
|
-
|
|
18716
|
-
|
|
18717
|
-
|
|
18718
|
-
|
|
18719
|
-
|
|
18720
|
-
|
|
18721
|
-
}
|
|
18722
|
-
return { participantIdsWithConflicts, eventsPublishStatuses };
|
|
18631
|
+
}
|
|
18632
|
+
return {
|
|
18633
|
+
participantIdsWithConflicts,
|
|
18634
|
+
eventsPublishStatuses,
|
|
18635
|
+
derivedEventInfo,
|
|
18636
|
+
derivedDrawInfo,
|
|
18637
|
+
mappedMatchUps,
|
|
18638
|
+
participantMap,
|
|
18639
|
+
matchUps
|
|
18640
|
+
};
|
|
18723
18641
|
}
|
|
18724
18642
|
|
|
18725
18643
|
function filterParticipants({
|
|
@@ -18839,117 +18757,134 @@ function getEventEntries({ eventEntryStatuses, tournamentEvents }) {
|
|
|
18839
18757
|
);
|
|
18840
18758
|
}
|
|
18841
18759
|
|
|
18842
|
-
function
|
|
18760
|
+
function getParticipants(params) {
|
|
18843
18761
|
const {
|
|
18762
|
+
withIndividualParticipants,
|
|
18844
18763
|
participantFilters = {},
|
|
18764
|
+
withPotentialMatchUps,
|
|
18765
|
+
withRankingProfile,
|
|
18845
18766
|
convertExtensions,
|
|
18846
18767
|
policyDefinitions,
|
|
18847
18768
|
withScheduleItems,
|
|
18769
|
+
tournamentRecord,
|
|
18848
18770
|
scheduleAnalysis,
|
|
18849
18771
|
withSignInStatus,
|
|
18850
18772
|
withTeamMatchUps,
|
|
18851
|
-
// not implemented
|
|
18852
|
-
tournamentRecord,
|
|
18853
|
-
usePublishState,
|
|
18854
18773
|
withScaleValues,
|
|
18774
|
+
usePublishState,
|
|
18775
|
+
contextProfile,
|
|
18855
18776
|
withStatistics,
|
|
18856
|
-
withGroupings,
|
|
18857
18777
|
withOpponents,
|
|
18858
18778
|
withMatchUps,
|
|
18779
|
+
internalUse,
|
|
18859
18780
|
withSeeding,
|
|
18860
18781
|
withEvents,
|
|
18861
18782
|
withDraws,
|
|
18862
|
-
inContext,
|
|
18863
18783
|
withISO2,
|
|
18864
18784
|
withIOC
|
|
18865
18785
|
} = params;
|
|
18866
18786
|
if (!tournamentRecord)
|
|
18867
18787
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
18868
|
-
if (
|
|
18869
|
-
|
|
18870
|
-
|
|
18871
|
-
|
|
18872
|
-
|
|
18873
|
-
|
|
18874
|
-
|
|
18875
|
-
|
|
18876
|
-
|
|
18877
|
-
|
|
18878
|
-
|
|
18879
|
-
|
|
18880
|
-
|
|
18881
|
-
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
|
|
18885
|
-
|
|
18886
|
-
|
|
18887
|
-
|
|
18788
|
+
if (withMatchUps || withRankingProfile) {
|
|
18789
|
+
getMatchUpDependencies({ tournamentRecord });
|
|
18790
|
+
}
|
|
18791
|
+
let { participantMap } = getParticipantMap({
|
|
18792
|
+
withIndividualParticipants,
|
|
18793
|
+
convertExtensions,
|
|
18794
|
+
tournamentRecord,
|
|
18795
|
+
withSignInStatus,
|
|
18796
|
+
withScaleValues,
|
|
18797
|
+
internalUse,
|
|
18798
|
+
withISO2,
|
|
18799
|
+
withIOC
|
|
18800
|
+
});
|
|
18801
|
+
const entriesResult = getParticipantEntries({
|
|
18802
|
+
withMatchUps: withMatchUps ?? withRankingProfile,
|
|
18803
|
+
withEvents: withEvents ?? withRankingProfile,
|
|
18804
|
+
withDraws: withDraws ?? withRankingProfile,
|
|
18805
|
+
withPotentialMatchUps,
|
|
18806
|
+
participantFilters,
|
|
18807
|
+
withRankingProfile,
|
|
18808
|
+
convertExtensions,
|
|
18809
|
+
withScheduleItems,
|
|
18810
|
+
policyDefinitions,
|
|
18811
|
+
tournamentRecord,
|
|
18812
|
+
scheduleAnalysis,
|
|
18813
|
+
withTeamMatchUps,
|
|
18814
|
+
usePublishState,
|
|
18815
|
+
withStatistics,
|
|
18816
|
+
participantMap,
|
|
18817
|
+
withOpponents,
|
|
18818
|
+
contextProfile,
|
|
18819
|
+
withSeeding
|
|
18820
|
+
});
|
|
18821
|
+
const {
|
|
18822
|
+
participantIdsWithConflicts,
|
|
18823
|
+
eventsPublishStatuses,
|
|
18824
|
+
derivedEventInfo,
|
|
18825
|
+
derivedDrawInfo,
|
|
18826
|
+
mappedMatchUps
|
|
18827
|
+
} = entriesResult;
|
|
18828
|
+
const matchUps = entriesResult.matchUps;
|
|
18829
|
+
participantMap = entriesResult.participantMap;
|
|
18830
|
+
const nextMatchUps = scheduleAnalysis ?? withPotentialMatchUps;
|
|
18831
|
+
const processedParticipants = Object.values(participantMap).map(
|
|
18832
|
+
({
|
|
18833
|
+
potentialMatchUps,
|
|
18834
|
+
scheduleConflicts,
|
|
18835
|
+
participant,
|
|
18836
|
+
statistics,
|
|
18837
|
+
opponents,
|
|
18838
|
+
matchUps: matchUps2,
|
|
18839
|
+
events,
|
|
18840
|
+
draws
|
|
18841
|
+
}) => {
|
|
18842
|
+
const participantDraws = Object.values(draws);
|
|
18843
|
+
const participantOpponents = Object.values(opponents);
|
|
18844
|
+
if (withOpponents) {
|
|
18845
|
+
participantDraws?.forEach((draw) => {
|
|
18846
|
+
draw.opponents = participantOpponents.filter(
|
|
18847
|
+
(opponent) => opponent.drawId === draw.drawId
|
|
18888
18848
|
);
|
|
18889
|
-
if (withScaleValues) {
|
|
18890
|
-
const { ratings, rankings } = getScaleValues({
|
|
18891
|
-
participant: individualParticipant
|
|
18892
|
-
});
|
|
18893
|
-
individualParticipant.ratings = ratings;
|
|
18894
|
-
individualParticipant.rankings = rankings;
|
|
18895
|
-
}
|
|
18896
|
-
if (withIOC || withISO2)
|
|
18897
|
-
addNationalityCode({
|
|
18898
|
-
participant: individualParticipant,
|
|
18899
|
-
withISO2,
|
|
18900
|
-
withIOC
|
|
18901
|
-
});
|
|
18902
|
-
return individualParticipant;
|
|
18903
18849
|
});
|
|
18904
18850
|
}
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
18851
|
+
return definedAttributes(
|
|
18852
|
+
{
|
|
18853
|
+
...participant,
|
|
18854
|
+
scheduleConflicts: scheduleAnalysis ? scheduleConflicts : void 0,
|
|
18855
|
+
draws: withDraws || withRankingProfile ? participantDraws : void 0,
|
|
18856
|
+
events: withEvents || withRankingProfile ? Object.values(events) : void 0,
|
|
18857
|
+
matchUps: withMatchUps || withRankingProfile ? Object.values(matchUps2) : void 0,
|
|
18858
|
+
opponents: withOpponents ? participantOpponents : void 0,
|
|
18859
|
+
potentialMatchUps: nextMatchUps ? Object.values(potentialMatchUps) : void 0,
|
|
18860
|
+
statistics: withStatistics ? Object.values(statistics) : void 0
|
|
18861
|
+
},
|
|
18862
|
+
false,
|
|
18863
|
+
false,
|
|
18864
|
+
true
|
|
18865
|
+
);
|
|
18866
|
+
}
|
|
18867
|
+
);
|
|
18868
|
+
const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
|
|
18869
|
+
const template = participantAttributes?.participant;
|
|
18870
|
+
const filteredParticipants = filterParticipants({
|
|
18871
|
+
participants: processedParticipants,
|
|
18909
18872
|
participantFilters,
|
|
18910
18873
|
tournamentRecord
|
|
18911
|
-
})
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
const result = addParticipantContext({
|
|
18916
|
-
tournamentEvents: tournamentRecord.events,
|
|
18917
|
-
allTournamentParticipants,
|
|
18918
|
-
tournamentParticipants,
|
|
18919
|
-
participantFilters,
|
|
18920
|
-
withScheduleItems,
|
|
18921
|
-
withSignInStatus,
|
|
18922
|
-
tournamentRecord,
|
|
18923
|
-
scheduleAnalysis,
|
|
18924
|
-
withTeamMatchUps,
|
|
18925
|
-
usePublishState,
|
|
18926
|
-
withScaleValues,
|
|
18927
|
-
withStatistics,
|
|
18928
|
-
withGroupings,
|
|
18929
|
-
withOpponents,
|
|
18930
|
-
withMatchUps,
|
|
18931
|
-
withSeeding,
|
|
18932
|
-
withEvents,
|
|
18933
|
-
withDraws,
|
|
18934
|
-
withISO2,
|
|
18935
|
-
withIOC
|
|
18936
|
-
});
|
|
18937
|
-
participantIdsWithConflicts = result?.participantIdsWithConflicts;
|
|
18938
|
-
eventsPublishStatuses = result?.eventsPublishStatuses;
|
|
18939
|
-
}
|
|
18940
|
-
const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
|
|
18941
|
-
if (participantAttributes?.participant) {
|
|
18942
|
-
tournamentParticipants = tournamentParticipants.map(
|
|
18943
|
-
(participant) => attributeFilter({
|
|
18944
|
-
template: participantAttributes.participant,
|
|
18945
|
-
source: participant
|
|
18946
|
-
})
|
|
18947
|
-
);
|
|
18948
|
-
}
|
|
18874
|
+
});
|
|
18875
|
+
const participants = template ? filteredParticipants.map(
|
|
18876
|
+
(source) => attributeFilter({ source, template })
|
|
18877
|
+
) : filteredParticipants;
|
|
18949
18878
|
return {
|
|
18950
18879
|
participantIdsWithConflicts,
|
|
18951
|
-
|
|
18952
|
-
|
|
18880
|
+
eventsPublishStatuses,
|
|
18881
|
+
derivedEventInfo,
|
|
18882
|
+
derivedDrawInfo,
|
|
18883
|
+
mappedMatchUps,
|
|
18884
|
+
participantMap,
|
|
18885
|
+
participants,
|
|
18886
|
+
...SUCCESS,
|
|
18887
|
+
matchUps
|
|
18953
18888
|
};
|
|
18954
18889
|
}
|
|
18955
18890
|
|
|
@@ -19120,11 +19055,11 @@ function createGroupParticipant({
|
|
|
19120
19055
|
info: "Invalid individualParticipantIds",
|
|
19121
19056
|
error: INVALID_VALUES
|
|
19122
19057
|
};
|
|
19123
|
-
const
|
|
19058
|
+
const participants = getParticipants({
|
|
19124
19059
|
participantFilters: { participantTypes: [INDIVIDUAL] },
|
|
19125
19060
|
tournamentRecord
|
|
19126
|
-
});
|
|
19127
|
-
const tournamentIndividualParticipantIds =
|
|
19061
|
+
}).participants ?? [];
|
|
19062
|
+
const tournamentIndividualParticipantIds = participants.map(
|
|
19128
19063
|
(participant) => participant.participantId
|
|
19129
19064
|
);
|
|
19130
19065
|
for (const participantId2 of individualParticipantIds) {
|
|
@@ -19542,10 +19477,10 @@ function generateVoluntaryConsolation$1(params) {
|
|
|
19542
19477
|
let drawDefinition = params?.drawDefinition;
|
|
19543
19478
|
if (!drawDefinition)
|
|
19544
19479
|
return { error: MISSING_DRAW_DEFINITION };
|
|
19545
|
-
const
|
|
19546
|
-
|
|
19547
|
-
|
|
19548
|
-
})?.
|
|
19480
|
+
const participants = tournamentRecord ? getParticipants({
|
|
19481
|
+
withIndividualParticipants: true,
|
|
19482
|
+
tournamentRecord
|
|
19483
|
+
})?.participants : [];
|
|
19549
19484
|
const stage = VOLUNTARY_CONSOLATION;
|
|
19550
19485
|
const entries = getStageEntries({
|
|
19551
19486
|
stageSequence: 1,
|
|
@@ -19636,10 +19571,10 @@ function generateVoluntaryConsolation$1(params) {
|
|
|
19636
19571
|
if (automated) {
|
|
19637
19572
|
automatedPositioning$1({
|
|
19638
19573
|
seedingProfile: params.seedingProfile,
|
|
19639
|
-
participants: tournamentParticipants,
|
|
19640
19574
|
applyPositioning,
|
|
19641
19575
|
tournamentRecord,
|
|
19642
19576
|
drawDefinition,
|
|
19577
|
+
participants,
|
|
19643
19578
|
structureId,
|
|
19644
19579
|
placeByes,
|
|
19645
19580
|
drawSize,
|
|
@@ -20916,9 +20851,7 @@ function addDrawDefinition(params) {
|
|
|
20916
20851
|
});
|
|
20917
20852
|
if (relevantFlight && !drawEntriesPresentInFlight) {
|
|
20918
20853
|
return decorateResult({
|
|
20919
|
-
result: {
|
|
20920
|
-
error: INVALID_DRAW_DEFINITION
|
|
20921
|
-
},
|
|
20854
|
+
result: { error: INVALID_DRAW_DEFINITION },
|
|
20922
20855
|
context: {
|
|
20923
20856
|
drawEntriesPresentInFlight,
|
|
20924
20857
|
matchingEventEntries,
|
|
@@ -23003,9 +22936,9 @@ function generateDrawDefinition(params) {
|
|
|
23003
22936
|
}).appliedPolicies ?? {};
|
|
23004
22937
|
const drawTypeCoercion = params.drawTypeCoercion ?? appliedPolicies?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? true;
|
|
23005
22938
|
const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
23006
|
-
const {
|
|
23007
|
-
|
|
23008
|
-
|
|
22939
|
+
const { participants } = getParticipants({
|
|
22940
|
+
withIndividualParticipants: true,
|
|
22941
|
+
tournamentRecord
|
|
23009
22942
|
});
|
|
23010
22943
|
const enforceGender = params.enforceGender ?? policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender;
|
|
23011
22944
|
const allowedDrawTypes = !ignoreAllowedDrawTypes && tournamentRecord && getAllowedDrawTypes({
|