tods-competition-factory 1.8.14 → 1.8.16
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.d.ts +1 -0
- package/dist/forge/generate.mjs +103 -82
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +1 -2
- package/dist/forge/query.mjs +69 -58
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.d.ts +1 -0
- package/dist/forge/transform.mjs +51 -43
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +331 -100
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +470 -128
- 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 +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2382,7 +2382,7 @@ const matchUpFormatCode = {
|
|
|
2382
2382
|
};
|
|
2383
2383
|
|
|
2384
2384
|
function factoryVersion() {
|
|
2385
|
-
return "1.8.
|
|
2385
|
+
return "1.8.16";
|
|
2386
2386
|
}
|
|
2387
2387
|
|
|
2388
2388
|
function getObjectTieFormat(obj) {
|
|
@@ -3189,11 +3189,11 @@ function countSets({
|
|
|
3189
3189
|
score
|
|
3190
3190
|
}) {
|
|
3191
3191
|
const setsTally = [0, 0];
|
|
3192
|
-
const
|
|
3193
|
-
const matchUpWinnerIndex = matchUpWinningSide - 1;
|
|
3192
|
+
const sets = score?.sets;
|
|
3193
|
+
const matchUpWinnerIndex = typeof matchUpWinningSide === "number" && matchUpWinningSide - 1;
|
|
3194
3194
|
const parsedMatchUpFormat = parse(matchUpFormat);
|
|
3195
3195
|
const setsToWin = getSetsToWin(parsedMatchUpFormat?.bestOf ?? 1);
|
|
3196
|
-
if (matchUpStatus === DEFAULTED && tallyPolicy?.setsCreditForDefaults || matchUpStatus === WALKOVER$2 && tallyPolicy?.setsCreditForWalkovers) {
|
|
3196
|
+
if (typeof matchUpWinnerIndex === "number" && (matchUpStatus === DEFAULTED && tallyPolicy?.setsCreditForDefaults || matchUpStatus === WALKOVER$2 && tallyPolicy?.setsCreditForWalkovers)) {
|
|
3197
3197
|
setsTally[matchUpWinnerIndex] = setsToWin;
|
|
3198
3198
|
} else {
|
|
3199
3199
|
for (const set of sets || []) {
|
|
@@ -3202,7 +3202,7 @@ function countSets({
|
|
|
3202
3202
|
setsTally[setWinningSide - 1] += 1;
|
|
3203
3203
|
}
|
|
3204
3204
|
}
|
|
3205
|
-
if (matchUpStatus === RETIRED$1) {
|
|
3205
|
+
if (typeof matchUpWinnerIndex === "number" && matchUpStatus === RETIRED$1) {
|
|
3206
3206
|
if (+setsTally[1 - matchUpWinnerIndex] === setsToWin)
|
|
3207
3207
|
setsTally[1 - matchUpWinnerIndex] -= 1;
|
|
3208
3208
|
if (tallyPolicy?.setsCreditForRetirements)
|
|
@@ -3220,13 +3220,13 @@ function countGames({
|
|
|
3220
3220
|
const { sets } = score || {};
|
|
3221
3221
|
if (!sets)
|
|
3222
3222
|
return [0, 0];
|
|
3223
|
-
const matchUpWinnerIndex = matchUpWinningSide - 1;
|
|
3223
|
+
const matchUpWinnerIndex = typeof matchUpWinningSide === "number" && matchUpWinningSide - 1;
|
|
3224
3224
|
const parsedMatchUpFormat = parse(matchUpFormat);
|
|
3225
3225
|
const bestOf = parsedMatchUpFormat?.bestOf ?? 1;
|
|
3226
3226
|
const setsToWin = getSetsToWin(bestOf);
|
|
3227
3227
|
const tiebreakAt = parsedMatchUpFormat?.setFormat?.tiebreakAt || 0;
|
|
3228
3228
|
const gamesTally = [[], []];
|
|
3229
|
-
if (matchUpStatus === DEFAULTED && tallyPolicy?.gamesCreditForDefaults || matchUpStatus === WALKOVER$2 && tallyPolicy?.gamesCreditForWalkovers) {
|
|
3229
|
+
if (typeof matchUpWinnerIndex === "number" && (matchUpStatus === DEFAULTED && tallyPolicy?.gamesCreditForDefaults || matchUpStatus === WALKOVER$2 && tallyPolicy?.gamesCreditForWalkovers)) {
|
|
3230
3230
|
const gamesForSet = parsedMatchUpFormat?.setFormat?.setTo || 0;
|
|
3231
3231
|
const minimumGameWins = setsToWin * gamesForSet;
|
|
3232
3232
|
gamesTally[matchUpWinnerIndex].push(minimumGameWins);
|
|
@@ -3246,7 +3246,7 @@ function countGames({
|
|
|
3246
3246
|
}
|
|
3247
3247
|
});
|
|
3248
3248
|
}
|
|
3249
|
-
if (matchUpStatus === RETIRED$1) {
|
|
3249
|
+
if (matchUpStatus === RETIRED$1 && typeof matchUpWinnerIndex === "number") {
|
|
3250
3250
|
const whichFormat = sets.length > setsToWin && parsedMatchUpFormat?.finalSetFormat ? "finalSetFormat" : "setFormat";
|
|
3251
3251
|
const format = parsedMatchUpFormat?.[whichFormat];
|
|
3252
3252
|
if (isGamesBased(format.based)) {
|
|
@@ -3286,10 +3286,14 @@ function countGames({
|
|
|
3286
3286
|
gamesTally[1].reduce((a, b) => a + b, 0)
|
|
3287
3287
|
];
|
|
3288
3288
|
}
|
|
3289
|
-
function countPoints({
|
|
3290
|
-
|
|
3289
|
+
function countPoints({
|
|
3290
|
+
matchUpFormat,
|
|
3291
|
+
score
|
|
3292
|
+
}) {
|
|
3293
|
+
const parsedMatchUpFormat = matchUpFormat ? parse(matchUpFormat) : void 0;
|
|
3291
3294
|
const bestOf = parsedMatchUpFormat?.bestOf ?? 1;
|
|
3292
3295
|
const setsToWin = getSetsToWin(bestOf);
|
|
3296
|
+
const tiebreaksTally = [0, 0];
|
|
3293
3297
|
const pointsTally = [0, 0];
|
|
3294
3298
|
score?.sets?.forEach((set, i) => {
|
|
3295
3299
|
const setNumber = set.setNumber || i + 1;
|
|
@@ -3306,9 +3310,11 @@ function countPoints({ matchUpFormat, score }) {
|
|
|
3306
3310
|
pointsTally[0] += ensureInt(set.side1TiebreakScore || 0);
|
|
3307
3311
|
if (set.side2TiebreakScore)
|
|
3308
3312
|
pointsTally[1] += ensureInt(set.side2TiebreakScore || 0);
|
|
3313
|
+
if ((set.side1TiebreakScore || set.side2TiebreakScore) && set.winningSide)
|
|
3314
|
+
tiebreaksTally[set.winningSide - 1] += 1;
|
|
3309
3315
|
}
|
|
3310
3316
|
});
|
|
3311
|
-
return pointsTally;
|
|
3317
|
+
return { pointsTally, tiebreaksTally };
|
|
3312
3318
|
}
|
|
3313
3319
|
function getSetsToWin(bestOfGames) {
|
|
3314
3320
|
return bestOfGames && Math.ceil(bestOfGames / 2) || 1;
|
|
@@ -3423,7 +3429,7 @@ function getParticipantResults({
|
|
|
3423
3429
|
const winningParticipantId = winningSide && getWinningSideId(matchUp);
|
|
3424
3430
|
const losingParticipantId = winningSide && getLosingSideId(matchUp);
|
|
3425
3431
|
if (!winningParticipantId && !losingParticipantId) {
|
|
3426
|
-
if (completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
3432
|
+
if (matchUpStatus && completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
3427
3433
|
const participantIdSide1 = getSideId(matchUp, 0);
|
|
3428
3434
|
const participantIdSide2 = getSideId(matchUp, 1);
|
|
3429
3435
|
if (participantIdSide1) {
|
|
@@ -3438,10 +3444,10 @@ function getParticipantResults({
|
|
|
3438
3444
|
perPlayer = 0;
|
|
3439
3445
|
for (const tieMatchUp of tieMatchUps) {
|
|
3440
3446
|
if (tieMatchUp.winningSide) {
|
|
3441
|
-
const tieWinningParticipantId = sides
|
|
3447
|
+
const tieWinningParticipantId = sides?.find(
|
|
3442
3448
|
({ sideNumber }) => sideNumber === tieMatchUp.winningSide
|
|
3443
3449
|
)?.participantId;
|
|
3444
|
-
const tieLosingParticipantId = sides
|
|
3450
|
+
const tieLosingParticipantId = sides?.find(
|
|
3445
3451
|
({ sideNumber }) => sideNumber === tieMatchUp.winningSide
|
|
3446
3452
|
)?.participantId;
|
|
3447
3453
|
if (tieWinningParticipantId && tieLosingParticipantId) {
|
|
@@ -3560,26 +3566,30 @@ function getParticipantResults({
|
|
|
3560
3566
|
}
|
|
3561
3567
|
}
|
|
3562
3568
|
if (manualGamesOverride) {
|
|
3563
|
-
const side1participantId = sides
|
|
3569
|
+
const side1participantId = sides?.find(
|
|
3564
3570
|
({ sideNumber }) => sideNumber === 1
|
|
3565
3571
|
)?.participantId;
|
|
3566
|
-
const side2participantId = sides
|
|
3572
|
+
const side2participantId = sides?.find(
|
|
3567
3573
|
({ sideNumber }) => sideNumber === 2
|
|
3568
3574
|
)?.participantId;
|
|
3569
3575
|
checkInitializeParticipant(participantResults, side1participantId);
|
|
3570
3576
|
checkInitializeParticipant(participantResults, side2participantId);
|
|
3571
|
-
const gamesWonSide1 = score
|
|
3572
|
-
(total, set) => total + set
|
|
3577
|
+
const gamesWonSide1 = score?.sets?.reduce(
|
|
3578
|
+
(total, set) => total + (set?.side1Score ?? 0),
|
|
3573
3579
|
0
|
|
3574
3580
|
);
|
|
3575
|
-
const gamesWonSide2 = score
|
|
3576
|
-
(total, set) => total + set.side2Score,
|
|
3581
|
+
const gamesWonSide2 = score?.sets?.reduce(
|
|
3582
|
+
(total, set) => total + (set.side2Score ?? 0),
|
|
3577
3583
|
0
|
|
3578
3584
|
);
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3585
|
+
if (side1participantId) {
|
|
3586
|
+
participantResults[side1participantId].gamesWon += gamesWonSide1;
|
|
3587
|
+
participantResults[side1participantId].gamesLost += gamesWonSide2;
|
|
3588
|
+
}
|
|
3589
|
+
if (side2participantId) {
|
|
3590
|
+
participantResults[side2participantId].gamesWon += gamesWonSide2;
|
|
3591
|
+
participantResults[side2participantId].gamesLost += gamesWonSide1;
|
|
3592
|
+
}
|
|
3583
3593
|
}
|
|
3584
3594
|
}
|
|
3585
3595
|
calculatePercentages({
|
|
@@ -3706,7 +3716,7 @@ function processMatchUp$1({
|
|
|
3706
3716
|
winningSide,
|
|
3707
3717
|
score
|
|
3708
3718
|
});
|
|
3709
|
-
const pointsTally = countPoints({ score, matchUpFormat });
|
|
3719
|
+
const { pointsTally } = countPoints({ score, matchUpFormat });
|
|
3710
3720
|
if (winningParticipantId) {
|
|
3711
3721
|
participantResults[winningParticipantId].setsWon += setsTally[winningSideIndex];
|
|
3712
3722
|
participantResults[winningParticipantId].setsLost += setsTally[losingSideIndex];
|
|
@@ -15597,6 +15607,21 @@ function addNationalityCode({
|
|
|
15597
15607
|
persons.forEach(annotatePerson);
|
|
15598
15608
|
}
|
|
15599
15609
|
|
|
15610
|
+
function addIndividualParticipants({ participantMap }) {
|
|
15611
|
+
const participantObjects = Object.values(participantMap);
|
|
15612
|
+
for (const participantObject of participantObjects) {
|
|
15613
|
+
const participant = participantObject.participant;
|
|
15614
|
+
if (participant.individualParticipantIds?.length) {
|
|
15615
|
+
participant.individualParticipants = [];
|
|
15616
|
+
for (const participantId of participant.individualParticipantIds) {
|
|
15617
|
+
participant.individualParticipants.push(
|
|
15618
|
+
participantMap[participantId].participant
|
|
15619
|
+
);
|
|
15620
|
+
}
|
|
15621
|
+
}
|
|
15622
|
+
}
|
|
15623
|
+
}
|
|
15624
|
+
|
|
15600
15625
|
function getTimeItem({
|
|
15601
15626
|
returnPreviousValues,
|
|
15602
15627
|
itemSubTypes,
|
|
@@ -15778,20 +15803,6 @@ function signedIn(participant) {
|
|
|
15778
15803
|
});
|
|
15779
15804
|
return timeItem?.itemValue === SIGNED_IN;
|
|
15780
15805
|
}
|
|
15781
|
-
function addIndividualParticipants({ participantMap }) {
|
|
15782
|
-
const participantObjects = Object.values(participantMap);
|
|
15783
|
-
for (const participantObject of participantObjects) {
|
|
15784
|
-
const participant = participantObject.participant;
|
|
15785
|
-
if (participant.individualParticipantIds?.length) {
|
|
15786
|
-
participant.individualParticipants = [];
|
|
15787
|
-
for (const participantId of participant.individualParticipantIds) {
|
|
15788
|
-
participant.individualParticipants.push(
|
|
15789
|
-
participantMap[participantId].participant
|
|
15790
|
-
);
|
|
15791
|
-
}
|
|
15792
|
-
}
|
|
15793
|
-
}
|
|
15794
|
-
}
|
|
15795
15806
|
function processIndividualParticipantIds({
|
|
15796
15807
|
individualParticipantIds,
|
|
15797
15808
|
participantCopy,
|
|
@@ -16070,7 +16081,6 @@ function allEventMatchUps(params) {
|
|
|
16070
16081
|
if (!event)
|
|
16071
16082
|
return { error: MISSING_EVENT };
|
|
16072
16083
|
const { eventId, eventName, endDate, category, gender, matchUpFormat } = event;
|
|
16073
|
-
const eventMatchUps2 = [];
|
|
16074
16084
|
const additionalContext = {
|
|
16075
16085
|
...context,
|
|
16076
16086
|
...definedAttributes({
|
|
@@ -16114,7 +16124,7 @@ function allEventMatchUps(params) {
|
|
|
16114
16124
|
}).scheduleTiming;
|
|
16115
16125
|
const matchUps = drawDefinitions.flatMap(
|
|
16116
16126
|
(drawDefinition) => {
|
|
16117
|
-
const { matchUps: matchUps2
|
|
16127
|
+
const { matchUps: matchUps2 } = getAllDrawMatchUps({
|
|
16118
16128
|
tournamentParticipants: participants,
|
|
16119
16129
|
tournamentAppliedPolicies,
|
|
16120
16130
|
scheduleVisibilityFilters,
|
|
@@ -16134,12 +16144,10 @@ function allEventMatchUps(params) {
|
|
|
16134
16144
|
inContext,
|
|
16135
16145
|
event
|
|
16136
16146
|
});
|
|
16137
|
-
if (matchUpsMap?.drawMatchUps)
|
|
16138
|
-
eventMatchUps2.push(...matchUpsMap.drawMatchUps);
|
|
16139
16147
|
return matchUps2 ?? [];
|
|
16140
16148
|
}
|
|
16141
16149
|
);
|
|
16142
|
-
return { matchUps
|
|
16150
|
+
return { matchUps };
|
|
16143
16151
|
}
|
|
16144
16152
|
function tournamentMatchUps(params) {
|
|
16145
16153
|
if (!params?.tournamentRecord)
|
|
@@ -27850,7 +27858,6 @@ function getParticipants$1(params) {
|
|
|
27850
27858
|
getMatchUpDependencies({ tournamentRecord });
|
|
27851
27859
|
}
|
|
27852
27860
|
let { participantMap } = getParticipantMap({
|
|
27853
|
-
withIndividualParticipants,
|
|
27854
27861
|
convertExtensions,
|
|
27855
27862
|
tournamentRecord,
|
|
27856
27863
|
withSignInStatus,
|
|
@@ -27889,45 +27896,48 @@ function getParticipants$1(params) {
|
|
|
27889
27896
|
const matchUps = entriesResult.matchUps;
|
|
27890
27897
|
participantMap = entriesResult.participantMap;
|
|
27891
27898
|
const nextMatchUps = scheduleAnalysis ?? withPotentialMatchUps;
|
|
27892
|
-
const
|
|
27893
|
-
|
|
27894
|
-
|
|
27895
|
-
|
|
27896
|
-
|
|
27897
|
-
|
|
27898
|
-
|
|
27899
|
-
|
|
27900
|
-
|
|
27901
|
-
|
|
27902
|
-
|
|
27903
|
-
|
|
27904
|
-
|
|
27905
|
-
|
|
27906
|
-
|
|
27907
|
-
|
|
27908
|
-
|
|
27909
|
-
|
|
27910
|
-
|
|
27911
|
-
});
|
|
27912
|
-
}
|
|
27913
|
-
return definedAttributes(
|
|
27914
|
-
{
|
|
27915
|
-
...participant,
|
|
27916
|
-
scheduleConflicts: scheduleAnalysis ? scheduleConflicts : void 0,
|
|
27917
|
-
draws: withDraws || withRankingProfile ? participantDraws : void 0,
|
|
27918
|
-
events: withEvents || withRankingProfile ? Object.values(events) : void 0,
|
|
27919
|
-
matchUps: withMatchUps || withRankingProfile ? Object.values(matchUps2) : void 0,
|
|
27920
|
-
opponents: withOpponents ? participantOpponents : void 0,
|
|
27921
|
-
potentialMatchUps: nextMatchUps ? Object.values(potentialMatchUps) : void 0,
|
|
27922
|
-
statistics: withStatistics ? Object.values(statistics) : void 0,
|
|
27923
|
-
scheduleItems: withScheduleItems ? scheduleItems : void 0
|
|
27924
|
-
},
|
|
27925
|
-
false,
|
|
27926
|
-
false,
|
|
27927
|
-
true
|
|
27928
|
-
);
|
|
27899
|
+
const processParticipant = ({
|
|
27900
|
+
potentialMatchUps,
|
|
27901
|
+
scheduleConflicts,
|
|
27902
|
+
scheduleItems,
|
|
27903
|
+
participant,
|
|
27904
|
+
statistics,
|
|
27905
|
+
opponents,
|
|
27906
|
+
matchUps: matchUps2,
|
|
27907
|
+
events,
|
|
27908
|
+
draws
|
|
27909
|
+
}) => {
|
|
27910
|
+
const participantDraws = Object.values(draws);
|
|
27911
|
+
const participantOpponents = Object.values(opponents);
|
|
27912
|
+
if (withOpponents) {
|
|
27913
|
+
participantDraws?.forEach((draw) => {
|
|
27914
|
+
draw.opponents = participantOpponents.filter(
|
|
27915
|
+
(opponent) => opponent.drawId === draw.drawId
|
|
27916
|
+
);
|
|
27917
|
+
});
|
|
27929
27918
|
}
|
|
27930
|
-
|
|
27919
|
+
return definedAttributes(
|
|
27920
|
+
{
|
|
27921
|
+
...participant,
|
|
27922
|
+
scheduleConflicts: scheduleAnalysis ? scheduleConflicts : void 0,
|
|
27923
|
+
draws: withDraws || withRankingProfile ? participantDraws : void 0,
|
|
27924
|
+
events: withEvents || withRankingProfile ? Object.values(events) : void 0,
|
|
27925
|
+
matchUps: withMatchUps || withRankingProfile ? Object.values(matchUps2) : void 0,
|
|
27926
|
+
opponents: withOpponents ? participantOpponents : void 0,
|
|
27927
|
+
potentialMatchUps: nextMatchUps ? Object.values(potentialMatchUps) : void 0,
|
|
27928
|
+
statistics: withStatistics ? Object.values(statistics) : void 0,
|
|
27929
|
+
scheduleItems: withScheduleItems ? scheduleItems : void 0
|
|
27930
|
+
},
|
|
27931
|
+
false,
|
|
27932
|
+
false,
|
|
27933
|
+
true
|
|
27934
|
+
);
|
|
27935
|
+
};
|
|
27936
|
+
const ppMap = /* @__PURE__ */ new Map();
|
|
27937
|
+
for (const participantId of Object.keys(participantMap)) {
|
|
27938
|
+
ppMap.set(participantId, processParticipant(participantMap[participantId]));
|
|
27939
|
+
}
|
|
27940
|
+
const processedParticipants = [...ppMap.values()];
|
|
27931
27941
|
const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
|
|
27932
27942
|
const template = participantAttributes?.participant;
|
|
27933
27943
|
const filteredParticipants = filterParticipants({
|
|
@@ -27935,6 +27945,17 @@ function getParticipants$1(params) {
|
|
|
27935
27945
|
participantFilters,
|
|
27936
27946
|
tournamentRecord
|
|
27937
27947
|
});
|
|
27948
|
+
if (withIndividualParticipants) {
|
|
27949
|
+
for (const participant of filteredParticipants) {
|
|
27950
|
+
for (const individualParticipantId of participant.individualParticipantIds ?? []) {
|
|
27951
|
+
if (!participant.individualParticipants)
|
|
27952
|
+
participant.individualParticipants = [];
|
|
27953
|
+
participant.individualParticipants.push(
|
|
27954
|
+
ppMap.get(individualParticipantId)
|
|
27955
|
+
);
|
|
27956
|
+
}
|
|
27957
|
+
}
|
|
27958
|
+
}
|
|
27938
27959
|
const participants = template ? filteredParticipants.map(
|
|
27939
27960
|
(source) => attributeFilter({ source, template })
|
|
27940
27961
|
) : filteredParticipants;
|
|
@@ -37975,7 +37996,7 @@ function setState$4(records, deepCopyOption = true) {
|
|
|
37975
37996
|
function engineLogging({ result, methodName, elapsed, params, engine }) {
|
|
37976
37997
|
const devContext = getDevContext();
|
|
37977
37998
|
const log = { method: methodName };
|
|
37978
|
-
const logError = result
|
|
37999
|
+
const logError = result?.error && (devContext.errors === true || Array.isArray(devContext.errors) && devContext.errors.includes(methodName));
|
|
37979
38000
|
const specifiedMethodParams = Array.isArray(devContext.params) && devContext.params?.includes(methodName);
|
|
37980
38001
|
const logParams = devContext.params && !Array.isArray(devContext.params) || specifiedMethodParams;
|
|
37981
38002
|
const exclude = Array.isArray(devContext.exclude) && devContext.exclude.includes(methodName);
|
|
@@ -37989,7 +38010,7 @@ function engineLogging({ result, methodName, elapsed, params, engine }) {
|
|
|
37989
38010
|
}
|
|
37990
38011
|
if (Object.keys(log).length > 1)
|
|
37991
38012
|
console.log(engine, log);
|
|
37992
|
-
if (devContext.makeDeepCopy)
|
|
38013
|
+
if (result && devContext.makeDeepCopy)
|
|
37993
38014
|
result.deepCopyIterations = getDeepCopyIterations();
|
|
37994
38015
|
}
|
|
37995
38016
|
|
|
@@ -43525,7 +43546,7 @@ function buildDrawHierarchy({
|
|
|
43525
43546
|
const firstRoundDrawPositions = firstRoundPairedDrawPositions.flat(Infinity);
|
|
43526
43547
|
const secondRoundDrawPositions = secondRoundMatchUps.map((matchUp) => matchUp.drawPositions).flat(Infinity);
|
|
43527
43548
|
const secondRoundEntries = secondRoundDrawPositions.filter((drawPosition) => !firstRoundDrawPositions.includes(drawPosition)).sort(drawPositionSort);
|
|
43528
|
-
const
|
|
43549
|
+
const secondRoundEntrySides = secondRoundMatchUps.filter(
|
|
43529
43550
|
(matchUp) => matchUp.drawPositions?.reduce(
|
|
43530
43551
|
(p, c) => secondRoundEntries.includes(c) || p,
|
|
43531
43552
|
void 0
|
|
@@ -43543,7 +43564,7 @@ function buildDrawHierarchy({
|
|
|
43543
43564
|
const missingPairs = secondRoundEntries.map((drawPosition, index) => {
|
|
43544
43565
|
return [drawPosition, missingDrawPositions[index]].sort(drawPositionSort);
|
|
43545
43566
|
});
|
|
43546
|
-
const entrySides = Object.assign({}, ...
|
|
43567
|
+
const entrySides = Object.assign({}, ...secondRoundEntrySides);
|
|
43547
43568
|
const finishingRound = makeDeepCopy(
|
|
43548
43569
|
firstRoundMatchUps?.[0].finishingRound,
|
|
43549
43570
|
false,
|
|
@@ -54846,7 +54867,197 @@ function getPositionManipulations({ extensions }) {
|
|
|
54846
54867
|
return extensions?.find(({ name }) => name === AUDIT_POSITION_ACTIONS)?.value?.slice(1);
|
|
54847
54868
|
}
|
|
54848
54869
|
|
|
54849
|
-
|
|
54870
|
+
function getTeamStats({
|
|
54871
|
+
opponentParticipantId,
|
|
54872
|
+
teamParticipantId,
|
|
54873
|
+
tournamentRecord,
|
|
54874
|
+
tallyPolicy,
|
|
54875
|
+
matchUps
|
|
54876
|
+
}) {
|
|
54877
|
+
if (!tournamentRecord)
|
|
54878
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
54879
|
+
if (matchUps && !Array.isArray(matchUps))
|
|
54880
|
+
return { error: INVALID_MATCHUP };
|
|
54881
|
+
matchUps = matchUps || allTournamentMatchUps({ tournamentRecord }).matchUps;
|
|
54882
|
+
if (!matchUps?.length)
|
|
54883
|
+
return { error: MISSING_MATCHUPS };
|
|
54884
|
+
const teamParticipantIds = [];
|
|
54885
|
+
if (opponentParticipantId)
|
|
54886
|
+
teamParticipantIds.push(opponentParticipantId);
|
|
54887
|
+
if (teamParticipantId)
|
|
54888
|
+
teamParticipantIds.push(teamParticipantId);
|
|
54889
|
+
const participantFilters = !teamParticipantIds.length ? { participantTypes: [TEAM_PARTICIPANT] } : { participantIds: teamParticipantIds };
|
|
54890
|
+
const teamParticipants = getParticipants$1({ participantFilters, tournamentRecord }).participants ?? [];
|
|
54891
|
+
if (!teamParticipants.every(
|
|
54892
|
+
({ participantType }) => participantType === TEAM_PARTICIPANT
|
|
54893
|
+
)) {
|
|
54894
|
+
return { error: INVALID_PARTICIPANT_IDS };
|
|
54895
|
+
}
|
|
54896
|
+
if (!teamParticipantIds.length)
|
|
54897
|
+
teamParticipantIds.push(...teamParticipants.map(extractAttributes("participantId")));
|
|
54898
|
+
const teamStats = /* @__PURE__ */ new Map();
|
|
54899
|
+
const teamMap = /* @__PURE__ */ new Map();
|
|
54900
|
+
for (const teamParticipant of teamParticipants) {
|
|
54901
|
+
const { participantId, individualParticipantIds } = teamParticipant;
|
|
54902
|
+
teamMap.set(participantId, individualParticipantIds ?? []);
|
|
54903
|
+
teamStats.set(participantId, {
|
|
54904
|
+
participantName: teamParticipant.participantName ?? "",
|
|
54905
|
+
matchUpStatuses: {},
|
|
54906
|
+
competitorIds: [],
|
|
54907
|
+
tiebreaks: [0, 0],
|
|
54908
|
+
matchUps: [0, 0],
|
|
54909
|
+
points: [0, 0],
|
|
54910
|
+
participantId,
|
|
54911
|
+
games: [0, 0],
|
|
54912
|
+
sets: [0, 0]
|
|
54913
|
+
});
|
|
54914
|
+
}
|
|
54915
|
+
if (teamParticipantId && !teamMap.get(teamParticipantId))
|
|
54916
|
+
return decorateResult({
|
|
54917
|
+
result: { error: PARTICIPANT_NOT_FOUND },
|
|
54918
|
+
context: { teamParticipantId }
|
|
54919
|
+
});
|
|
54920
|
+
if (opponentParticipantId && !teamMap.get(opponentParticipantId))
|
|
54921
|
+
return decorateResult({
|
|
54922
|
+
result: { error: PARTICIPANT_NOT_FOUND },
|
|
54923
|
+
context: { opponentParticipantId }
|
|
54924
|
+
});
|
|
54925
|
+
const relevantMatchUps = [];
|
|
54926
|
+
const getTeamParticipantIds = (sides) => {
|
|
54927
|
+
const sideTeamParticipantIds = [];
|
|
54928
|
+
const isTeamSide = (side, individualParticipantIds) => {
|
|
54929
|
+
return !!(side.participantId && individualParticipantIds.includes(side.participantId) || side.participant?.individualParticipantIds?.length && intersection(
|
|
54930
|
+
individualParticipantIds,
|
|
54931
|
+
side.participant?.individualParticipantIds
|
|
54932
|
+
).length === side.participant?.individualParticipantIds?.length);
|
|
54933
|
+
};
|
|
54934
|
+
for (const [teamParticipantId2, individualParticipantIds] of teamMap) {
|
|
54935
|
+
for (const side of sides) {
|
|
54936
|
+
if (!side.participant)
|
|
54937
|
+
continue;
|
|
54938
|
+
if (isTeamSide(side, individualParticipantIds)) {
|
|
54939
|
+
const sideNumber = side.sideNumber;
|
|
54940
|
+
if (!sideNumber)
|
|
54941
|
+
continue;
|
|
54942
|
+
sideTeamParticipantIds[sideNumber - 1] = teamParticipantId2;
|
|
54943
|
+
const competitorIds = side.participant?.individualParticipantIds?.length ? side.participant.individualParticipantIds : [side.participant.participantId];
|
|
54944
|
+
const stats = teamStats.get(teamParticipantId2);
|
|
54945
|
+
for (const id of competitorIds) {
|
|
54946
|
+
if (stats && !stats.competitorIds.includes(id))
|
|
54947
|
+
stats.competitorIds.push(id);
|
|
54948
|
+
}
|
|
54949
|
+
}
|
|
54950
|
+
}
|
|
54951
|
+
}
|
|
54952
|
+
return sideTeamParticipantIds;
|
|
54953
|
+
};
|
|
54954
|
+
for (const matchUp of matchUps) {
|
|
54955
|
+
if (!isObject(matchUp))
|
|
54956
|
+
return { error: INVALID_MATCHUP };
|
|
54957
|
+
const {
|
|
54958
|
+
matchUpStatus,
|
|
54959
|
+
matchUpFormat,
|
|
54960
|
+
matchUpType,
|
|
54961
|
+
winningSide,
|
|
54962
|
+
score,
|
|
54963
|
+
sides
|
|
54964
|
+
} = matchUp;
|
|
54965
|
+
if (!sides || !score || matchUpType === TEAM_MATCHUP || matchUpStatus === BYE)
|
|
54966
|
+
continue;
|
|
54967
|
+
const teamParticipantIds2 = getTeamParticipantIds(sides);
|
|
54968
|
+
if (!teamParticipantIds2.filter(Boolean).length)
|
|
54969
|
+
continue;
|
|
54970
|
+
relevantMatchUps.push(matchUp);
|
|
54971
|
+
const setsTally = countSets({
|
|
54972
|
+
matchUpStatus,
|
|
54973
|
+
matchUpFormat,
|
|
54974
|
+
tallyPolicy,
|
|
54975
|
+
winningSide,
|
|
54976
|
+
score
|
|
54977
|
+
});
|
|
54978
|
+
const gamesTally = countGames({
|
|
54979
|
+
matchUpStatus,
|
|
54980
|
+
matchUpFormat,
|
|
54981
|
+
tallyPolicy,
|
|
54982
|
+
winningSide,
|
|
54983
|
+
score
|
|
54984
|
+
});
|
|
54985
|
+
const { pointsTally, tiebreaksTally } = countPoints({
|
|
54986
|
+
matchUpFormat,
|
|
54987
|
+
score
|
|
54988
|
+
});
|
|
54989
|
+
teamParticipantIds2.forEach((teamParticipantId2, index) => {
|
|
54990
|
+
if (teamParticipantId2) {
|
|
54991
|
+
const stats = teamStats.get(teamParticipantId2);
|
|
54992
|
+
if (stats) {
|
|
54993
|
+
const teamSumTally = (stat, tally) => tally.forEach((t, i) => stats[stat][i] += t);
|
|
54994
|
+
const tiebreaks = index ? [...tiebreaksTally].reverse() : tiebreaksTally;
|
|
54995
|
+
const points = index ? [...pointsTally].reverse() : pointsTally;
|
|
54996
|
+
const games = index ? [...gamesTally].reverse() : gamesTally;
|
|
54997
|
+
const sets = index ? [...setsTally].reverse() : setsTally;
|
|
54998
|
+
teamSumTally("tiebreaks", tiebreaks);
|
|
54999
|
+
teamSumTally("points", points);
|
|
55000
|
+
teamSumTally("games", games);
|
|
55001
|
+
teamSumTally("sets", sets);
|
|
55002
|
+
if (winningSide) {
|
|
55003
|
+
const tallyIndex = winningSide - 1 === index ? 0 : 1;
|
|
55004
|
+
stats.matchUps[tallyIndex] += 1;
|
|
55005
|
+
}
|
|
55006
|
+
if (matchUpStatus) {
|
|
55007
|
+
if (!stats.matchUpStatuses[matchUpStatus])
|
|
55008
|
+
stats.matchUpStatuses[matchUpStatus] = 0;
|
|
55009
|
+
stats.matchUpStatuses[matchUpStatus] += 1;
|
|
55010
|
+
}
|
|
55011
|
+
}
|
|
55012
|
+
}
|
|
55013
|
+
});
|
|
55014
|
+
}
|
|
55015
|
+
const attrs = ["tiebreaks", "matchUps", "points", "games", "sets"];
|
|
55016
|
+
const ratio = /* @__PURE__ */ new Map();
|
|
55017
|
+
const add = (a, b) => (a ?? 0) + (b ?? 0);
|
|
55018
|
+
for (const stats of teamStats.values()) {
|
|
55019
|
+
for (const attr of attrs) {
|
|
55020
|
+
const total = stats[attr].reduce(add);
|
|
55021
|
+
if (total) {
|
|
55022
|
+
const value = stats[attr][0] / total;
|
|
55023
|
+
const accessor = `${attr}Ratio`;
|
|
55024
|
+
const fixedValue = parseFloat(value.toFixed(2));
|
|
55025
|
+
stats[accessor] = fixedValue;
|
|
55026
|
+
if (!ratio.has(accessor))
|
|
55027
|
+
ratio.set(accessor, []);
|
|
55028
|
+
ratio.get(accessor)?.push(fixedValue);
|
|
55029
|
+
}
|
|
55030
|
+
}
|
|
55031
|
+
}
|
|
55032
|
+
const highLowSort = (a, b) => b - a;
|
|
55033
|
+
for (const stats of teamStats.values()) {
|
|
55034
|
+
for (const attr of attrs) {
|
|
55035
|
+
const accessor = `${attr}Ratio`;
|
|
55036
|
+
if (typeof stats[accessor] === "number") {
|
|
55037
|
+
const index = ratio.get(accessor)?.sort(highLowSort).indexOf(stats[accessor]);
|
|
55038
|
+
if (typeof index === "number" && index >= 0) {
|
|
55039
|
+
const rankAccessor = `${attr}Rank`;
|
|
55040
|
+
stats[rankAccessor] = index + 1;
|
|
55041
|
+
}
|
|
55042
|
+
}
|
|
55043
|
+
}
|
|
55044
|
+
}
|
|
55045
|
+
const result = { relevantMatchUps, ...SUCCESS };
|
|
55046
|
+
if (teamParticipantId) {
|
|
55047
|
+
result.teamStats = teamStats.get(teamParticipantId);
|
|
55048
|
+
if (opponentParticipantId)
|
|
55049
|
+
result.opponentStats = teamStats.get(opponentParticipantId);
|
|
55050
|
+
} else {
|
|
55051
|
+
result.allTeamStats = [...teamStats.values()];
|
|
55052
|
+
}
|
|
55053
|
+
return result;
|
|
55054
|
+
}
|
|
55055
|
+
|
|
55056
|
+
const reportGovernor = {
|
|
55057
|
+
getStructureReports,
|
|
55058
|
+
getEntryStatusReports,
|
|
55059
|
+
getTeamStats
|
|
55060
|
+
};
|
|
54850
55061
|
|
|
54851
55062
|
function setDrawParticipantRepresentativeIds({
|
|
54852
55063
|
representativeParticipantIds,
|
|
@@ -59090,7 +59301,7 @@ function aggregateTieFormats({
|
|
|
59090
59301
|
}
|
|
59091
59302
|
}
|
|
59092
59303
|
const setTieFormatId = (matchUpId, tieFormatId) => {
|
|
59093
|
-
const matchUp = eventMatchUpResult.
|
|
59304
|
+
const matchUp = eventMatchUpResult.matchUps?.find(
|
|
59094
59305
|
(matchUp2) => matchUp2.matchUpId === matchUpId
|
|
59095
59306
|
);
|
|
59096
59307
|
if (matchUp) {
|
|
@@ -59368,6 +59579,7 @@ function getMaxEntryPosition(params) {
|
|
|
59368
59579
|
function getPredictiveAccuracy(params) {
|
|
59369
59580
|
let { matchUps } = params;
|
|
59370
59581
|
const {
|
|
59582
|
+
singlesForDoubles,
|
|
59371
59583
|
tournamentRecord,
|
|
59372
59584
|
drawDefinition,
|
|
59373
59585
|
excludeMargin,
|
|
@@ -59442,6 +59654,7 @@ function getPredictiveAccuracy(params) {
|
|
|
59442
59654
|
const marginCalc = !zoneDoubling || matchUpType === SINGLES$1 ? zoneMargin : (zoneMargin || 0) * 2;
|
|
59443
59655
|
const zoneData = zoneMargin ? relevantMatchUps.map(({ competitiveProfile, matchUpType: matchUpType2, score, sides }) => {
|
|
59444
59656
|
const sideValues = getSideValues({
|
|
59657
|
+
singlesForDoubles,
|
|
59445
59658
|
valueAccessor,
|
|
59446
59659
|
matchUpType: matchUpType2,
|
|
59447
59660
|
scaleName,
|
|
@@ -59485,6 +59698,7 @@ function getGroupingBands({ zoneData }) {
|
|
|
59485
59698
|
return bands;
|
|
59486
59699
|
}
|
|
59487
59700
|
function getSideValues({
|
|
59701
|
+
singlesForDoubles,
|
|
59488
59702
|
exclusionRule,
|
|
59489
59703
|
valueAccessor,
|
|
59490
59704
|
matchUpType,
|
|
@@ -59505,6 +59719,7 @@ function getSideValues({
|
|
|
59505
59719
|
let value = 0;
|
|
59506
59720
|
for (const participant2 of individualParticipants) {
|
|
59507
59721
|
const { scaleValue, value: pValue } = getSideValue({
|
|
59722
|
+
singlesForDoubles,
|
|
59508
59723
|
valueAccessor,
|
|
59509
59724
|
participant: participant2,
|
|
59510
59725
|
matchUpType,
|
|
@@ -59528,6 +59743,7 @@ function getSideValues({
|
|
|
59528
59743
|
};
|
|
59529
59744
|
} else if (participant) {
|
|
59530
59745
|
const { scaleValue, value } = getSideValue({
|
|
59746
|
+
singlesForDoubles,
|
|
59531
59747
|
valueAccessor,
|
|
59532
59748
|
matchUpType,
|
|
59533
59749
|
participant,
|
|
@@ -59547,11 +59763,18 @@ function getSideValues({
|
|
|
59547
59763
|
}
|
|
59548
59764
|
});
|
|
59549
59765
|
}
|
|
59550
|
-
function getSideValue({
|
|
59551
|
-
|
|
59766
|
+
function getSideValue({
|
|
59767
|
+
singlesForDoubles,
|
|
59768
|
+
valueAccessor,
|
|
59769
|
+
matchUpType,
|
|
59770
|
+
participant,
|
|
59771
|
+
scaleName
|
|
59772
|
+
}) {
|
|
59773
|
+
const type = singlesForDoubles ? SINGLES$1 : matchUpType;
|
|
59774
|
+
const ranking = participant?.rankings?.[type]?.find(
|
|
59552
59775
|
(ranking2) => ranking2.scaleName === scaleName
|
|
59553
59776
|
);
|
|
59554
|
-
const rating = participant?.ratings?.[
|
|
59777
|
+
const rating = participant?.ratings?.[type]?.find(
|
|
59555
59778
|
(rating2) => rating2.scaleName === scaleName
|
|
59556
59779
|
);
|
|
59557
59780
|
const scaleValue = (rating || ranking)?.scaleValue;
|
|
@@ -59832,11 +60055,15 @@ function getEvents({
|
|
|
59832
60055
|
}
|
|
59833
60056
|
const ratings = eventsMap[eventId].ratings;
|
|
59834
60057
|
for (const scaleName of Object.keys(ratings)) {
|
|
60058
|
+
const scaleRating = ratings[scaleName];
|
|
60059
|
+
if (!scaleRating.length)
|
|
60060
|
+
continue;
|
|
60061
|
+
const med = median(scaleRating)?.toFixed(2);
|
|
59835
60062
|
eventsMap[eventId].ratingsStats[scaleName] = {
|
|
59836
|
-
avg: sum(
|
|
59837
|
-
median:
|
|
59838
|
-
max: Math.max(...
|
|
59839
|
-
min: Math.min(...
|
|
60063
|
+
avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
|
|
60064
|
+
median: med ? parseFloat(med) : void 0,
|
|
60065
|
+
max: Math.max(...scaleRating),
|
|
60066
|
+
min: Math.min(...scaleRating)
|
|
59840
60067
|
};
|
|
59841
60068
|
}
|
|
59842
60069
|
const processFlight = (drawId, participantIds2) => {
|
|
@@ -59899,11 +60126,15 @@ function getEvents({
|
|
|
59899
60126
|
for (const drawId of processedDrawIds) {
|
|
59900
60127
|
const ratings2 = eventsMap[eventId].draws[drawId].ratings;
|
|
59901
60128
|
for (const scaleName of Object.keys(ratings2)) {
|
|
60129
|
+
const scaleRating = ratings2[scaleName];
|
|
60130
|
+
if (!scaleRating.length)
|
|
60131
|
+
continue;
|
|
60132
|
+
const med = median(scaleRating)?.toFixed(2);
|
|
59902
60133
|
eventsMap[eventId].draws[drawId].ratingsStats[scaleName] = {
|
|
59903
|
-
avg: sum(
|
|
59904
|
-
|
|
59905
|
-
|
|
59906
|
-
|
|
60134
|
+
avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
|
|
60135
|
+
median: med ? parseFloat(med) : void 0,
|
|
60136
|
+
max: Math.max(...scaleRating),
|
|
60137
|
+
min: Math.min(...scaleRating)
|
|
59907
60138
|
};
|
|
59908
60139
|
}
|
|
59909
60140
|
}
|