tods-competition-factory 1.8.40 → 1.8.42
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 +4 -1
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +4 -0
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +343 -235
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +516 -394
- 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 +6 -6
package/dist/index.mjs
CHANGED
|
@@ -2404,7 +2404,7 @@ const matchUpFormatCode = {
|
|
|
2404
2404
|
};
|
|
2405
2405
|
|
|
2406
2406
|
function factoryVersion() {
|
|
2407
|
-
return "1.8.
|
|
2407
|
+
return "1.8.42";
|
|
2408
2408
|
}
|
|
2409
2409
|
|
|
2410
2410
|
function getObjectTieFormat(obj) {
|
|
@@ -15218,6 +15218,10 @@ const JUNIOR = "JUNIOR";
|
|
|
15218
15218
|
const WHEELCHAIR = "WHEELCHAIR";
|
|
15219
15219
|
const POLICY_SCHEDULING_DEFAULT = {
|
|
15220
15220
|
[POLICY_TYPE_SCHEDULING]: {
|
|
15221
|
+
allowModificationWhenMatchUpsScheduled: {
|
|
15222
|
+
courts: false,
|
|
15223
|
+
venues: false
|
|
15224
|
+
},
|
|
15221
15225
|
defaultTimes: {
|
|
15222
15226
|
averageTimes: [{ categoryNames: [], minutes: { default: 90 } }],
|
|
15223
15227
|
recoveryTimes: [{ minutes: { [DOUBLES$1]: 30, default: 60 } }]
|
|
@@ -15503,6 +15507,10 @@ const POLICY_SCORING_USTA = {
|
|
|
15503
15507
|
const POLICY_SCORING_DEFAULT = {
|
|
15504
15508
|
[POLICY_TYPE_SCORING]: {
|
|
15505
15509
|
defaultMatchUpFormat: FORMAT_STANDARD,
|
|
15510
|
+
allowDeletionWithScoresPresent: {
|
|
15511
|
+
drawDefinitions: false,
|
|
15512
|
+
structures: false
|
|
15513
|
+
},
|
|
15506
15514
|
requireAllPositionsAssigned: false,
|
|
15507
15515
|
processCodes: {
|
|
15508
15516
|
incompleteAssignmentsOnDefault: ["RANKING.IGNORE"]
|
|
@@ -20765,6 +20773,7 @@ function bulkScheduleMatchUps$1({
|
|
|
20765
20773
|
errorOnAnachronism = false,
|
|
20766
20774
|
checkChronology = true,
|
|
20767
20775
|
matchUpDependencies,
|
|
20776
|
+
removePriorValues,
|
|
20768
20777
|
tournamentRecords,
|
|
20769
20778
|
tournamentRecord,
|
|
20770
20779
|
matchUpDetails,
|
|
@@ -20781,7 +20790,10 @@ function bulkScheduleMatchUps$1({
|
|
|
20781
20790
|
const warnings = [];
|
|
20782
20791
|
let scheduled = 0;
|
|
20783
20792
|
if (checkChronology && !matchUpDependencies) {
|
|
20784
|
-
const result = getMatchUpDependencies({
|
|
20793
|
+
const result = getMatchUpDependencies({
|
|
20794
|
+
tournamentRecords,
|
|
20795
|
+
tournamentRecord
|
|
20796
|
+
});
|
|
20785
20797
|
matchUpDependencies = result.matchUpDependencies;
|
|
20786
20798
|
inContextMatchUps = result.matchUps;
|
|
20787
20799
|
}
|
|
@@ -20822,6 +20834,7 @@ function bulkScheduleMatchUps$1({
|
|
|
20822
20834
|
schedule: matchUpSchedule,
|
|
20823
20835
|
matchUpDependencies,
|
|
20824
20836
|
errorOnAnachronism,
|
|
20837
|
+
removePriorValues,
|
|
20825
20838
|
inContextMatchUps,
|
|
20826
20839
|
tournamentRecords,
|
|
20827
20840
|
tournamentRecord,
|
|
@@ -20846,6 +20859,7 @@ function bulkScheduleMatchUps({
|
|
|
20846
20859
|
scheduleByeMatchUps = false,
|
|
20847
20860
|
errorOnAnachronism,
|
|
20848
20861
|
matchUpContextIds,
|
|
20862
|
+
removePriorValues,
|
|
20849
20863
|
tournamentRecords,
|
|
20850
20864
|
checkChronology,
|
|
20851
20865
|
matchUpDetails,
|
|
@@ -20875,6 +20889,7 @@ function bulkScheduleMatchUps({
|
|
|
20875
20889
|
scheduleByeMatchUps,
|
|
20876
20890
|
matchUpDependencies,
|
|
20877
20891
|
errorOnAnachronism,
|
|
20892
|
+
removePriorValues,
|
|
20878
20893
|
tournamentRecords,
|
|
20879
20894
|
tournamentRecord,
|
|
20880
20895
|
checkChronology,
|
|
@@ -32560,13 +32575,16 @@ function processAlreadyScheduledMatchUps({
|
|
|
32560
32575
|
minutesMap,
|
|
32561
32576
|
matchUps
|
|
32562
32577
|
}) {
|
|
32563
|
-
const
|
|
32578
|
+
const byeScheduledMatchUpDetails = [];
|
|
32564
32579
|
if (!dateScheduledMatchUpIds) {
|
|
32565
32580
|
dateScheduledMatchUps = matchUps?.filter((matchUp) => {
|
|
32566
32581
|
const schedule = matchUp.schedule || {};
|
|
32567
32582
|
const isByeMatchUp = matchUp.matchUpStatus === BYE;
|
|
32568
32583
|
if (isByeMatchUp)
|
|
32569
|
-
|
|
32584
|
+
byeScheduledMatchUpDetails.push({
|
|
32585
|
+
tournamentId: matchUp.tournamentId,
|
|
32586
|
+
matchUpId: matchUp.matchUpId
|
|
32587
|
+
});
|
|
32570
32588
|
return !isByeMatchUp && hasSchedule({ schedule }) && (!scheduleDate || matchUp.schedule.scheduledDate === scheduleDate);
|
|
32571
32589
|
});
|
|
32572
32590
|
dateScheduledMatchUpIds = dateScheduledMatchUps.map(getMatchUpId);
|
|
@@ -32601,7 +32619,7 @@ function processAlreadyScheduledMatchUps({
|
|
|
32601
32619
|
}
|
|
32602
32620
|
return {
|
|
32603
32621
|
dateScheduledMatchUpIds,
|
|
32604
|
-
|
|
32622
|
+
byeScheduledMatchUpDetails,
|
|
32605
32623
|
dateScheduledMatchUps,
|
|
32606
32624
|
clearDate
|
|
32607
32625
|
};
|
|
@@ -32640,10 +32658,10 @@ function getGroupedRounds({
|
|
|
32640
32658
|
}
|
|
32641
32659
|
if (groupedMatchUpIds.length) {
|
|
32642
32660
|
groupedRounds.push({
|
|
32643
|
-
|
|
32644
|
-
recoveryMinutes,
|
|
32661
|
+
matchUpIds: groupedMatchUpIds,
|
|
32645
32662
|
roundPeriodLength,
|
|
32646
|
-
|
|
32663
|
+
recoveryMinutes,
|
|
32664
|
+
averageMinutes
|
|
32647
32665
|
});
|
|
32648
32666
|
}
|
|
32649
32667
|
return { groupedRounds };
|
|
@@ -32859,7 +32877,7 @@ function getVenueSchedulingDetails({
|
|
|
32859
32877
|
}) {
|
|
32860
32878
|
const venueScheduledRoundDetails = {};
|
|
32861
32879
|
const allDateScheduledMatchUpIds = [];
|
|
32862
|
-
const
|
|
32880
|
+
const allDateScheduledByeMatchUpDetails = [];
|
|
32863
32881
|
const allDateMatchUpIds = [];
|
|
32864
32882
|
for (const venue of venues) {
|
|
32865
32883
|
const { rounds = [], venueId } = venue;
|
|
@@ -32910,9 +32928,9 @@ function getVenueSchedulingDetails({
|
|
|
32910
32928
|
matchUps
|
|
32911
32929
|
});
|
|
32912
32930
|
({ dateScheduledMatchUpIds, dateScheduledMatchUps } = processResult);
|
|
32913
|
-
const {
|
|
32914
|
-
if (
|
|
32915
|
-
|
|
32931
|
+
const { byeScheduledMatchUpDetails, clearDate } = processResult;
|
|
32932
|
+
if (byeScheduledMatchUpDetails?.length)
|
|
32933
|
+
allDateScheduledByeMatchUpDetails.push(...byeScheduledMatchUpDetails);
|
|
32916
32934
|
const { matchUpsToSchedule, matchUpMap } = getMatchUpsToSchedule({
|
|
32917
32935
|
matchUpPotentialParticipantIds,
|
|
32918
32936
|
scheduleCompletedMatchUps,
|
|
@@ -32943,7 +32961,7 @@ function getVenueSchedulingDetails({
|
|
|
32943
32961
|
}
|
|
32944
32962
|
}
|
|
32945
32963
|
return {
|
|
32946
|
-
|
|
32964
|
+
allDateScheduledByeMatchUpDetails,
|
|
32947
32965
|
allDateScheduledMatchUpIds,
|
|
32948
32966
|
venueScheduledRoundDetails,
|
|
32949
32967
|
allDateMatchUpIds
|
|
@@ -33111,8 +33129,8 @@ function jinnScheduler({
|
|
|
33111
33129
|
matchUpDependencies,
|
|
33112
33130
|
matchUpDailyLimits,
|
|
33113
33131
|
clearScheduleDates,
|
|
33114
|
-
schedulingProfile,
|
|
33115
33132
|
tournamentRecords,
|
|
33133
|
+
schedulingProfile,
|
|
33116
33134
|
personRequests,
|
|
33117
33135
|
periodLength,
|
|
33118
33136
|
matchUps,
|
|
@@ -33165,7 +33183,11 @@ function jinnScheduler({
|
|
|
33165
33183
|
});
|
|
33166
33184
|
}
|
|
33167
33185
|
});
|
|
33168
|
-
const {
|
|
33186
|
+
const {
|
|
33187
|
+
allDateScheduledByeMatchUpDetails,
|
|
33188
|
+
venueScheduledRoundDetails,
|
|
33189
|
+
allDateMatchUpIds
|
|
33190
|
+
} = getVenueSchedulingDetails({
|
|
33169
33191
|
matchUpPotentialParticipantIds,
|
|
33170
33192
|
individualParticipantProfiles,
|
|
33171
33193
|
scheduleCompletedMatchUps,
|
|
@@ -33359,6 +33381,21 @@ function jinnScheduler({
|
|
|
33359
33381
|
(a, b) => timeStringMinutes(a.scheduleTime) - timeStringMinutes(b.scheduleTime)
|
|
33360
33382
|
);
|
|
33361
33383
|
}
|
|
33384
|
+
if (!dryRun && allDateScheduledByeMatchUpDetails?.length) {
|
|
33385
|
+
bulkScheduleMatchUps({
|
|
33386
|
+
matchUpDetails: allDateScheduledByeMatchUpDetails,
|
|
33387
|
+
scheduleByeMatchUps: true,
|
|
33388
|
+
removePriorValues: true,
|
|
33389
|
+
tournamentRecords,
|
|
33390
|
+
schedule: {
|
|
33391
|
+
scheduledDate: "",
|
|
33392
|
+
scheduledTime: "",
|
|
33393
|
+
courtOrder: "",
|
|
33394
|
+
courtId: "",
|
|
33395
|
+
venueId: ""
|
|
33396
|
+
}
|
|
33397
|
+
});
|
|
33398
|
+
}
|
|
33362
33399
|
for (const venue of dateSchedulingProfile.venues) {
|
|
33363
33400
|
for (const round of venue.rounds) {
|
|
33364
33401
|
const matchUpIds = round.matchUps?.map(({ matchUpId }) => matchUpId) || [];
|
|
@@ -33409,6 +33446,179 @@ function jinnScheduler({
|
|
|
33409
33446
|
};
|
|
33410
33447
|
}
|
|
33411
33448
|
|
|
33449
|
+
function getPersonRequests({
|
|
33450
|
+
tournamentRecords,
|
|
33451
|
+
requestType
|
|
33452
|
+
}) {
|
|
33453
|
+
if (typeof tournamentRecords !== "object" || !Object.keys(tournamentRecords).length)
|
|
33454
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33455
|
+
const personRequests = {};
|
|
33456
|
+
for (const tournamentRecord of Object.values(tournamentRecords)) {
|
|
33457
|
+
const { extension } = findTournamentExtension({
|
|
33458
|
+
name: PERSON_REQUESTS,
|
|
33459
|
+
tournamentRecord
|
|
33460
|
+
});
|
|
33461
|
+
const requestObjects = extension?.value || [];
|
|
33462
|
+
for (const requestObject of requestObjects) {
|
|
33463
|
+
const { personId, requests } = requestObject || {};
|
|
33464
|
+
if (!personRequests[personId])
|
|
33465
|
+
personRequests[personId] = [];
|
|
33466
|
+
for (const request of requests) {
|
|
33467
|
+
if (requestType && request.requestType !== requestType)
|
|
33468
|
+
continue;
|
|
33469
|
+
personRequests[personId].push(request);
|
|
33470
|
+
}
|
|
33471
|
+
}
|
|
33472
|
+
}
|
|
33473
|
+
return { personRequests };
|
|
33474
|
+
}
|
|
33475
|
+
function savePersonRequests({
|
|
33476
|
+
tournamentRecords,
|
|
33477
|
+
personRequests
|
|
33478
|
+
}) {
|
|
33479
|
+
if (!tournamentRecords)
|
|
33480
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33481
|
+
if (!personRequests)
|
|
33482
|
+
return { ...SUCCESS };
|
|
33483
|
+
const tournaments = Object.values(tournamentRecords);
|
|
33484
|
+
for (const tournamentRecord of tournaments) {
|
|
33485
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
33486
|
+
const relevantPersonRequests = [];
|
|
33487
|
+
for (const personId of Object.keys(personRequests)) {
|
|
33488
|
+
if (findParticipant({ tournamentParticipants, personId })) {
|
|
33489
|
+
const requests = personRequests[personId];
|
|
33490
|
+
if (requests.length)
|
|
33491
|
+
relevantPersonRequests.push({ personId, requests });
|
|
33492
|
+
}
|
|
33493
|
+
}
|
|
33494
|
+
if (Object.keys(relevantPersonRequests).length) {
|
|
33495
|
+
const extension = {
|
|
33496
|
+
name: PERSON_REQUESTS,
|
|
33497
|
+
value: relevantPersonRequests
|
|
33498
|
+
};
|
|
33499
|
+
addTournamentExtension({ tournamentRecord, extension });
|
|
33500
|
+
}
|
|
33501
|
+
}
|
|
33502
|
+
return { ...SUCCESS };
|
|
33503
|
+
}
|
|
33504
|
+
function addPersonRequests({
|
|
33505
|
+
tournamentRecords,
|
|
33506
|
+
personId,
|
|
33507
|
+
requests
|
|
33508
|
+
}) {
|
|
33509
|
+
if (!tournamentRecords)
|
|
33510
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33511
|
+
if (typeof personId !== "string")
|
|
33512
|
+
return { error: INVALID_VALUES };
|
|
33513
|
+
if (!Array.isArray(requests))
|
|
33514
|
+
return { error: INVALID_VALUES };
|
|
33515
|
+
const { personRequests } = getPersonRequests({ tournamentRecords });
|
|
33516
|
+
const { mergeCount } = mergePersonRequests({
|
|
33517
|
+
personRequests,
|
|
33518
|
+
personId,
|
|
33519
|
+
requests
|
|
33520
|
+
});
|
|
33521
|
+
if (mergeCount && personRequests) {
|
|
33522
|
+
return savePersonRequests({ tournamentRecords, personRequests });
|
|
33523
|
+
} else {
|
|
33524
|
+
return { error: INVALID_VALUES };
|
|
33525
|
+
}
|
|
33526
|
+
}
|
|
33527
|
+
function mergePersonRequests({ personRequests, personId, requests }) {
|
|
33528
|
+
if (!personRequests[personId])
|
|
33529
|
+
personRequests[personId] = [];
|
|
33530
|
+
const filteredRequests = requests.filter(({ requestType }) => requestType).map((request) => {
|
|
33531
|
+
let { date, startTime, endTime } = request;
|
|
33532
|
+
if (request.requestType === DO_NOT_SCHEDULE) {
|
|
33533
|
+
date = extractDate(date);
|
|
33534
|
+
startTime = extractTime(startTime);
|
|
33535
|
+
endTime = extractTime(endTime);
|
|
33536
|
+
if (date && startTime && endTime) {
|
|
33537
|
+
return { date, startTime, endTime, requestType: request.requestType };
|
|
33538
|
+
}
|
|
33539
|
+
}
|
|
33540
|
+
return request;
|
|
33541
|
+
}).filter(Boolean);
|
|
33542
|
+
for (const request of filteredRequests) {
|
|
33543
|
+
request.requestId = generateTimeCode();
|
|
33544
|
+
personRequests[personId].push(request);
|
|
33545
|
+
}
|
|
33546
|
+
return { mergeCount: filteredRequests.length };
|
|
33547
|
+
}
|
|
33548
|
+
function removePersonRequests({
|
|
33549
|
+
tournamentRecords,
|
|
33550
|
+
requestType,
|
|
33551
|
+
requestId,
|
|
33552
|
+
personId,
|
|
33553
|
+
date
|
|
33554
|
+
}) {
|
|
33555
|
+
if (typeof tournamentRecords !== "object" || !Object.keys(tournamentRecords).length)
|
|
33556
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33557
|
+
const { personRequests } = getPersonRequests({ tournamentRecords });
|
|
33558
|
+
const filterRequests = (personId2) => {
|
|
33559
|
+
if (personRequests) {
|
|
33560
|
+
personRequests[personId2] = personRequests[personId2].filter((request) => {
|
|
33561
|
+
return (!requestType || request.requestType !== requestType) && (!requestId || request.requestId !== requestId) && (!date || request.date !== date);
|
|
33562
|
+
});
|
|
33563
|
+
if (!personRequests?.[personId2]?.length)
|
|
33564
|
+
delete personRequests[personId2];
|
|
33565
|
+
}
|
|
33566
|
+
};
|
|
33567
|
+
const removeAll = !requestType && !requestId && !personId && !date;
|
|
33568
|
+
if (!removeAll) {
|
|
33569
|
+
if (personId && personRequests?.[personId]) {
|
|
33570
|
+
filterRequests(personId);
|
|
33571
|
+
} else if (personRequests) {
|
|
33572
|
+
for (const personId2 of Object.keys(personRequests)) {
|
|
33573
|
+
filterRequests(personId2);
|
|
33574
|
+
}
|
|
33575
|
+
}
|
|
33576
|
+
}
|
|
33577
|
+
if (removeAll || !personRequests || !Object.keys(personRequests).length) {
|
|
33578
|
+
return removeExtension({ tournamentRecords, name: PERSON_REQUESTS });
|
|
33579
|
+
} else {
|
|
33580
|
+
return savePersonRequests({ tournamentRecords, personRequests });
|
|
33581
|
+
}
|
|
33582
|
+
}
|
|
33583
|
+
function modifyPersonRequests({
|
|
33584
|
+
tournamentRecords,
|
|
33585
|
+
requests,
|
|
33586
|
+
personId
|
|
33587
|
+
}) {
|
|
33588
|
+
if (!tournamentRecords)
|
|
33589
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33590
|
+
if (!Array.isArray(requests))
|
|
33591
|
+
return { error: INVALID_VALUES };
|
|
33592
|
+
const requestIds = requests.map(({ requestId }) => requestId).filter(Boolean);
|
|
33593
|
+
const { personRequests } = getPersonRequests({ tournamentRecords });
|
|
33594
|
+
const modifyRequests = (personId2) => {
|
|
33595
|
+
if (personRequests) {
|
|
33596
|
+
personRequests[personId2] = personRequests[personId2].map((request) => {
|
|
33597
|
+
if (!requestIds.includes(request.requestId))
|
|
33598
|
+
return request;
|
|
33599
|
+
const modification = requests.find(
|
|
33600
|
+
(updatedRequest) => updatedRequest.requestId === request.requestId
|
|
33601
|
+
);
|
|
33602
|
+
if (!modification.requestType)
|
|
33603
|
+
return;
|
|
33604
|
+
return Object.assign(request, modification);
|
|
33605
|
+
}).filter(Boolean);
|
|
33606
|
+
}
|
|
33607
|
+
};
|
|
33608
|
+
if (personId && personRequests?.[personId]) {
|
|
33609
|
+
modifyRequests(personId);
|
|
33610
|
+
} else if (personRequests) {
|
|
33611
|
+
for (const personId2 of Object.keys(personRequests)) {
|
|
33612
|
+
modifyRequests(personId2);
|
|
33613
|
+
}
|
|
33614
|
+
}
|
|
33615
|
+
const newRequests = requests.filter((request) => !request.requestId);
|
|
33616
|
+
if (newRequests.length) {
|
|
33617
|
+
mergePersonRequests({ personRequests, personId, requests: newRequests });
|
|
33618
|
+
}
|
|
33619
|
+
return savePersonRequests({ tournamentRecords, personRequests });
|
|
33620
|
+
}
|
|
33621
|
+
|
|
33412
33622
|
function getEarliestCourtTime({
|
|
33413
33623
|
averageMinutes,
|
|
33414
33624
|
startTime,
|
|
@@ -33456,7 +33666,7 @@ function getEarliestCourtTime({
|
|
|
33456
33666
|
return { earliestCourtTime, courtStartTime, courtEndTime };
|
|
33457
33667
|
}
|
|
33458
33668
|
|
|
33459
|
-
function
|
|
33669
|
+
function v2Scheduler({
|
|
33460
33670
|
schedulingProfileModifications,
|
|
33461
33671
|
checkPotentialRequestConflicts,
|
|
33462
33672
|
scheduleCompletedMatchUps,
|
|
@@ -33471,7 +33681,7 @@ function proScheduler({
|
|
|
33471
33681
|
periodLength = 30,
|
|
33472
33682
|
schedulingProfile,
|
|
33473
33683
|
personRequests,
|
|
33474
|
-
matchUps,
|
|
33684
|
+
matchUps = [],
|
|
33475
33685
|
courts,
|
|
33476
33686
|
dryRun
|
|
33477
33687
|
}) {
|
|
@@ -33484,7 +33694,7 @@ function proScheduler({
|
|
|
33484
33694
|
const overLimitMatchUpIds = {};
|
|
33485
33695
|
const noTimeMatchUpIds = {};
|
|
33486
33696
|
const requestConflicts = {};
|
|
33487
|
-
for (const dateSchedulingProfile of dateSchedulingProfiles) {
|
|
33697
|
+
for (const dateSchedulingProfile of dateSchedulingProfiles ?? []) {
|
|
33488
33698
|
const scheduleDate = extractDate(dateSchedulingProfile?.scheduleDate);
|
|
33489
33699
|
const venues = dateSchedulingProfile?.venues || [];
|
|
33490
33700
|
const matchUpPotentialParticipantIds = {};
|
|
@@ -33509,7 +33719,7 @@ function proScheduler({
|
|
|
33509
33719
|
noTimeMatchUpIds[scheduleDate] = [];
|
|
33510
33720
|
requestConflicts[scheduleDate] = [];
|
|
33511
33721
|
const matchUpNotBeforeTimes = {};
|
|
33512
|
-
matchUps
|
|
33722
|
+
matchUps?.forEach((matchUp) => {
|
|
33513
33723
|
if (matchUp.schedule?.scheduledDate && sameDay(scheduleDate, extractDate(matchUp.schedule.scheduledDate))) {
|
|
33514
33724
|
processNextMatchUps({
|
|
33515
33725
|
matchUpPotentialParticipantIds,
|
|
@@ -33519,7 +33729,7 @@ function proScheduler({
|
|
|
33519
33729
|
}
|
|
33520
33730
|
});
|
|
33521
33731
|
const {
|
|
33522
|
-
|
|
33732
|
+
allDateScheduledByeMatchUpDetails,
|
|
33523
33733
|
allDateScheduledMatchUpIds,
|
|
33524
33734
|
venueScheduledRoundDetails,
|
|
33525
33735
|
allDateMatchUpIds
|
|
@@ -33539,7 +33749,7 @@ function proScheduler({
|
|
|
33539
33749
|
courts,
|
|
33540
33750
|
venues
|
|
33541
33751
|
});
|
|
33542
|
-
const dateScheduledMatchUps = matchUps
|
|
33752
|
+
const dateScheduledMatchUps = matchUps?.filter(
|
|
33543
33753
|
({ matchUpId }) => allDateScheduledMatchUpIds.includes(matchUpId)
|
|
33544
33754
|
);
|
|
33545
33755
|
const { bookings } = generateBookings({
|
|
@@ -33801,7 +34011,21 @@ function proScheduler({
|
|
|
33801
34011
|
getMatchUpId
|
|
33802
34012
|
);
|
|
33803
34013
|
}
|
|
33804
|
-
if (!dryRun &&
|
|
34014
|
+
if (!dryRun && allDateScheduledByeMatchUpDetails?.length) {
|
|
34015
|
+
bulkScheduleMatchUps({
|
|
34016
|
+
matchUpDetails: allDateScheduledByeMatchUpDetails,
|
|
34017
|
+
scheduleByeMatchUps: true,
|
|
34018
|
+
removePriorValues: true,
|
|
34019
|
+
tournamentRecords,
|
|
34020
|
+
schedule: {
|
|
34021
|
+
scheduledDate: "",
|
|
34022
|
+
scheduledTime: "",
|
|
34023
|
+
courtOrder: "",
|
|
34024
|
+
courtId: "",
|
|
34025
|
+
venueId: ""
|
|
34026
|
+
}
|
|
34027
|
+
});
|
|
34028
|
+
}
|
|
33805
34029
|
for (const venue of dateSchedulingProfile.venues) {
|
|
33806
34030
|
for (const round of venue.rounds) {
|
|
33807
34031
|
const matchUpIds = (round.matchUps ?? []).map(
|
|
@@ -33823,7 +34047,7 @@ function proScheduler({
|
|
|
33823
34047
|
}
|
|
33824
34048
|
}
|
|
33825
34049
|
}
|
|
33826
|
-
const scheduledDates = dateSchedulingProfiles.map(
|
|
34050
|
+
const scheduledDates = (dateSchedulingProfiles ?? []).map(
|
|
33827
34051
|
({ scheduleDate }) => scheduleDate
|
|
33828
34052
|
);
|
|
33829
34053
|
const autoSchedulingAudit = {
|
|
@@ -33852,179 +34076,6 @@ function proScheduler({
|
|
|
33852
34076
|
};
|
|
33853
34077
|
}
|
|
33854
34078
|
|
|
33855
|
-
function getPersonRequests({
|
|
33856
|
-
tournamentRecords,
|
|
33857
|
-
requestType
|
|
33858
|
-
}) {
|
|
33859
|
-
if (typeof tournamentRecords !== "object" || !Object.keys(tournamentRecords).length)
|
|
33860
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33861
|
-
const personRequests = {};
|
|
33862
|
-
for (const tournamentRecord of Object.values(tournamentRecords)) {
|
|
33863
|
-
const { extension } = findTournamentExtension({
|
|
33864
|
-
name: PERSON_REQUESTS,
|
|
33865
|
-
tournamentRecord
|
|
33866
|
-
});
|
|
33867
|
-
const requestObjects = extension?.value || [];
|
|
33868
|
-
for (const requestObject of requestObjects) {
|
|
33869
|
-
const { personId, requests } = requestObject || {};
|
|
33870
|
-
if (!personRequests[personId])
|
|
33871
|
-
personRequests[personId] = [];
|
|
33872
|
-
for (const request of requests) {
|
|
33873
|
-
if (requestType && request.requestType !== requestType)
|
|
33874
|
-
continue;
|
|
33875
|
-
personRequests[personId].push(request);
|
|
33876
|
-
}
|
|
33877
|
-
}
|
|
33878
|
-
}
|
|
33879
|
-
return { personRequests };
|
|
33880
|
-
}
|
|
33881
|
-
function savePersonRequests({
|
|
33882
|
-
tournamentRecords,
|
|
33883
|
-
personRequests
|
|
33884
|
-
}) {
|
|
33885
|
-
if (!tournamentRecords)
|
|
33886
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33887
|
-
if (!personRequests)
|
|
33888
|
-
return { ...SUCCESS };
|
|
33889
|
-
const tournaments = Object.values(tournamentRecords);
|
|
33890
|
-
for (const tournamentRecord of tournaments) {
|
|
33891
|
-
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
33892
|
-
const relevantPersonRequests = [];
|
|
33893
|
-
for (const personId of Object.keys(personRequests)) {
|
|
33894
|
-
if (findParticipant({ tournamentParticipants, personId })) {
|
|
33895
|
-
const requests = personRequests[personId];
|
|
33896
|
-
if (requests.length)
|
|
33897
|
-
relevantPersonRequests.push({ personId, requests });
|
|
33898
|
-
}
|
|
33899
|
-
}
|
|
33900
|
-
if (Object.keys(relevantPersonRequests).length) {
|
|
33901
|
-
const extension = {
|
|
33902
|
-
name: PERSON_REQUESTS,
|
|
33903
|
-
value: relevantPersonRequests
|
|
33904
|
-
};
|
|
33905
|
-
addTournamentExtension({ tournamentRecord, extension });
|
|
33906
|
-
}
|
|
33907
|
-
}
|
|
33908
|
-
return { ...SUCCESS };
|
|
33909
|
-
}
|
|
33910
|
-
function addPersonRequests({
|
|
33911
|
-
tournamentRecords,
|
|
33912
|
-
personId,
|
|
33913
|
-
requests
|
|
33914
|
-
}) {
|
|
33915
|
-
if (!tournamentRecords)
|
|
33916
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33917
|
-
if (typeof personId !== "string")
|
|
33918
|
-
return { error: INVALID_VALUES };
|
|
33919
|
-
if (!Array.isArray(requests))
|
|
33920
|
-
return { error: INVALID_VALUES };
|
|
33921
|
-
const { personRequests } = getPersonRequests({ tournamentRecords });
|
|
33922
|
-
const { mergeCount } = mergePersonRequests({
|
|
33923
|
-
personRequests,
|
|
33924
|
-
personId,
|
|
33925
|
-
requests
|
|
33926
|
-
});
|
|
33927
|
-
if (mergeCount && personRequests) {
|
|
33928
|
-
return savePersonRequests({ tournamentRecords, personRequests });
|
|
33929
|
-
} else {
|
|
33930
|
-
return { error: INVALID_VALUES };
|
|
33931
|
-
}
|
|
33932
|
-
}
|
|
33933
|
-
function mergePersonRequests({ personRequests, personId, requests }) {
|
|
33934
|
-
if (!personRequests[personId])
|
|
33935
|
-
personRequests[personId] = [];
|
|
33936
|
-
const filteredRequests = requests.filter(({ requestType }) => requestType).map((request) => {
|
|
33937
|
-
let { date, startTime, endTime } = request;
|
|
33938
|
-
if (request.requestType === DO_NOT_SCHEDULE) {
|
|
33939
|
-
date = extractDate(date);
|
|
33940
|
-
startTime = extractTime(startTime);
|
|
33941
|
-
endTime = extractTime(endTime);
|
|
33942
|
-
if (date && startTime && endTime) {
|
|
33943
|
-
return { date, startTime, endTime, requestType: request.requestType };
|
|
33944
|
-
}
|
|
33945
|
-
}
|
|
33946
|
-
return request;
|
|
33947
|
-
}).filter(Boolean);
|
|
33948
|
-
for (const request of filteredRequests) {
|
|
33949
|
-
request.requestId = generateTimeCode();
|
|
33950
|
-
personRequests[personId].push(request);
|
|
33951
|
-
}
|
|
33952
|
-
return { mergeCount: filteredRequests.length };
|
|
33953
|
-
}
|
|
33954
|
-
function removePersonRequests({
|
|
33955
|
-
tournamentRecords,
|
|
33956
|
-
requestType,
|
|
33957
|
-
requestId,
|
|
33958
|
-
personId,
|
|
33959
|
-
date
|
|
33960
|
-
}) {
|
|
33961
|
-
if (typeof tournamentRecords !== "object" || !Object.keys(tournamentRecords).length)
|
|
33962
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33963
|
-
const { personRequests } = getPersonRequests({ tournamentRecords });
|
|
33964
|
-
const filterRequests = (personId2) => {
|
|
33965
|
-
if (personRequests) {
|
|
33966
|
-
personRequests[personId2] = personRequests[personId2].filter((request) => {
|
|
33967
|
-
return (!requestType || request.requestType !== requestType) && (!requestId || request.requestId !== requestId) && (!date || request.date !== date);
|
|
33968
|
-
});
|
|
33969
|
-
if (!personRequests?.[personId2]?.length)
|
|
33970
|
-
delete personRequests[personId2];
|
|
33971
|
-
}
|
|
33972
|
-
};
|
|
33973
|
-
const removeAll = !requestType && !requestId && !personId && !date;
|
|
33974
|
-
if (!removeAll) {
|
|
33975
|
-
if (personId && personRequests?.[personId]) {
|
|
33976
|
-
filterRequests(personId);
|
|
33977
|
-
} else if (personRequests) {
|
|
33978
|
-
for (const personId2 of Object.keys(personRequests)) {
|
|
33979
|
-
filterRequests(personId2);
|
|
33980
|
-
}
|
|
33981
|
-
}
|
|
33982
|
-
}
|
|
33983
|
-
if (removeAll || !personRequests || !Object.keys(personRequests).length) {
|
|
33984
|
-
return removeExtension({ tournamentRecords, name: PERSON_REQUESTS });
|
|
33985
|
-
} else {
|
|
33986
|
-
return savePersonRequests({ tournamentRecords, personRequests });
|
|
33987
|
-
}
|
|
33988
|
-
}
|
|
33989
|
-
function modifyPersonRequests({
|
|
33990
|
-
tournamentRecords,
|
|
33991
|
-
requests,
|
|
33992
|
-
personId
|
|
33993
|
-
}) {
|
|
33994
|
-
if (!tournamentRecords)
|
|
33995
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
33996
|
-
if (!Array.isArray(requests))
|
|
33997
|
-
return { error: INVALID_VALUES };
|
|
33998
|
-
const requestIds = requests.map(({ requestId }) => requestId).filter(Boolean);
|
|
33999
|
-
const { personRequests } = getPersonRequests({ tournamentRecords });
|
|
34000
|
-
const modifyRequests = (personId2) => {
|
|
34001
|
-
if (personRequests) {
|
|
34002
|
-
personRequests[personId2] = personRequests[personId2].map((request) => {
|
|
34003
|
-
if (!requestIds.includes(request.requestId))
|
|
34004
|
-
return request;
|
|
34005
|
-
const modification = requests.find(
|
|
34006
|
-
(updatedRequest) => updatedRequest.requestId === request.requestId
|
|
34007
|
-
);
|
|
34008
|
-
if (!modification.requestType)
|
|
34009
|
-
return;
|
|
34010
|
-
return Object.assign(request, modification);
|
|
34011
|
-
}).filter(Boolean);
|
|
34012
|
-
}
|
|
34013
|
-
};
|
|
34014
|
-
if (personId && personRequests?.[personId]) {
|
|
34015
|
-
modifyRequests(personId);
|
|
34016
|
-
} else if (personRequests) {
|
|
34017
|
-
for (const personId2 of Object.keys(personRequests)) {
|
|
34018
|
-
modifyRequests(personId2);
|
|
34019
|
-
}
|
|
34020
|
-
}
|
|
34021
|
-
const newRequests = requests.filter((request) => !request.requestId);
|
|
34022
|
-
if (newRequests.length) {
|
|
34023
|
-
mergePersonRequests({ personRequests, personId, requests: newRequests });
|
|
34024
|
-
}
|
|
34025
|
-
return savePersonRequests({ tournamentRecords, personRequests });
|
|
34026
|
-
}
|
|
34027
|
-
|
|
34028
34079
|
function clearScheduledMatchUps$1({
|
|
34029
34080
|
scheduleAttributes = ["scheduledDate", "scheduledTime"],
|
|
34030
34081
|
ignoreMatchUpStatuses = completedMatchUpStatuses,
|
|
@@ -34136,6 +34187,7 @@ function scheduleProfileRounds({
|
|
|
34136
34187
|
scheduleDates = [],
|
|
34137
34188
|
tournamentRecords,
|
|
34138
34189
|
periodLength,
|
|
34190
|
+
useGarman,
|
|
34139
34191
|
dryRun,
|
|
34140
34192
|
pro
|
|
34141
34193
|
}) {
|
|
@@ -34147,9 +34199,9 @@ function scheduleProfileRounds({
|
|
|
34147
34199
|
if (result.error)
|
|
34148
34200
|
return result;
|
|
34149
34201
|
const {
|
|
34150
|
-
|
|
34202
|
+
modifications: schedulingProfileModifications,
|
|
34151
34203
|
issues: schedulingProfileIssues = [],
|
|
34152
|
-
|
|
34204
|
+
schedulingProfile = []
|
|
34153
34205
|
} = result;
|
|
34154
34206
|
const containedStructureIds = Object.assign(
|
|
34155
34207
|
{},
|
|
@@ -34174,10 +34226,10 @@ function scheduleProfileRounds({
|
|
|
34174
34226
|
const scheduledDates = Array.isArray(clearScheduleDates) ? clearScheduleDates : [];
|
|
34175
34227
|
clearScheduledMatchUps({ tournamentRecords, scheduledDates });
|
|
34176
34228
|
}
|
|
34177
|
-
const
|
|
34229
|
+
const courts = getVenuesAndCourts({
|
|
34178
34230
|
ignoreDisabled: false,
|
|
34179
34231
|
tournamentRecords
|
|
34180
|
-
});
|
|
34232
|
+
}).courts;
|
|
34181
34233
|
const { matchUps } = allCompetitionMatchUps({
|
|
34182
34234
|
matchUpFilters: { matchUpTypes: [SINGLES$1, DOUBLES$1] },
|
|
34183
34235
|
afterRecoveryTimes: true,
|
|
@@ -34214,12 +34266,13 @@ function scheduleProfileRounds({
|
|
|
34214
34266
|
schedulingProfile,
|
|
34215
34267
|
personRequests,
|
|
34216
34268
|
periodLength,
|
|
34269
|
+
useGarman,
|
|
34217
34270
|
matchUps,
|
|
34218
34271
|
dryRun,
|
|
34219
34272
|
courts
|
|
34220
34273
|
};
|
|
34221
34274
|
if (pro) {
|
|
34222
|
-
return
|
|
34275
|
+
return v2Scheduler(params);
|
|
34223
34276
|
} else {
|
|
34224
34277
|
return jinnScheduler(params);
|
|
34225
34278
|
}
|
|
@@ -37402,7 +37455,11 @@ function deleteVenue$1({
|
|
|
37402
37455
|
tournamentRecord,
|
|
37403
37456
|
contextFilters
|
|
37404
37457
|
}).matchUps ?? [];
|
|
37405
|
-
|
|
37458
|
+
const appliedPolicies = getAppliedPolicies({
|
|
37459
|
+
tournamentRecord
|
|
37460
|
+
})?.appliedPolicies;
|
|
37461
|
+
const allowModificationWhenMatchUpsScheduled = force ?? appliedPolicies?.[POLICY_TYPE_SCHEDULING]?.allowDeletionWithScoresPresent?.venues;
|
|
37462
|
+
if (!matchUpsToUnschedule.length || allowModificationWhenMatchUpsScheduled) {
|
|
37406
37463
|
for (const matchUp of matchUpsToUnschedule) {
|
|
37407
37464
|
const result = removeCourtAssignment({
|
|
37408
37465
|
matchUpId: matchUp.matchUpId,
|
|
@@ -37614,7 +37671,6 @@ function getScheduledVenueMatchUps({
|
|
|
37614
37671
|
|
|
37615
37672
|
function deleteCourt$1({
|
|
37616
37673
|
tournamentRecord,
|
|
37617
|
-
drawDefinition,
|
|
37618
37674
|
disableNotice,
|
|
37619
37675
|
courtId,
|
|
37620
37676
|
force
|
|
@@ -37627,13 +37683,16 @@ function deleteCourt$1({
|
|
|
37627
37683
|
tournamentRecord,
|
|
37628
37684
|
courtId
|
|
37629
37685
|
});
|
|
37630
|
-
|
|
37686
|
+
const appliedPolicies = getAppliedPolicies({
|
|
37687
|
+
tournamentRecord
|
|
37688
|
+
})?.appliedPolicies;
|
|
37689
|
+
const allowModificationWhenMatchUpsScheduled = force ?? appliedPolicies?.[POLICY_TYPE_SCHEDULING]?.allowDeletionWithScoresPresent?.courts;
|
|
37690
|
+
if (!matchUps?.length || allowModificationWhenMatchUpsScheduled) {
|
|
37631
37691
|
for (const matchUp of matchUps ?? []) {
|
|
37632
37692
|
const result2 = removeCourtAssignment({
|
|
37633
37693
|
matchUpId: matchUp.matchUpId,
|
|
37634
37694
|
drawId: matchUp.drawId,
|
|
37635
|
-
tournamentRecord
|
|
37636
|
-
drawDefinition
|
|
37695
|
+
tournamentRecord
|
|
37637
37696
|
});
|
|
37638
37697
|
if (result2.error)
|
|
37639
37698
|
return result2;
|
|
@@ -37822,7 +37881,19 @@ function modifyCourtAvailability({
|
|
|
37822
37881
|
courtId
|
|
37823
37882
|
});
|
|
37824
37883
|
if (courtMatchUps?.length) {
|
|
37825
|
-
|
|
37884
|
+
const appliedPolicies = getAppliedPolicies({
|
|
37885
|
+
tournamentRecord
|
|
37886
|
+
})?.appliedPolicies;
|
|
37887
|
+
const allowModificationWhenMatchUpsScheduled = force ?? appliedPolicies?.[POLICY_TYPE_SCHEDULING]?.allowDeletionWithScoresPresent?.courts;
|
|
37888
|
+
const matchUpsWithInvalidScheduling = [];
|
|
37889
|
+
if (matchUpsWithInvalidScheduling.length) {
|
|
37890
|
+
if (allowModificationWhenMatchUpsScheduled) ; else {
|
|
37891
|
+
console.log(
|
|
37892
|
+
"throw error: scheduled court matchUps",
|
|
37893
|
+
matchUpsWithInvalidScheduling.length
|
|
37894
|
+
);
|
|
37895
|
+
}
|
|
37896
|
+
}
|
|
37826
37897
|
}
|
|
37827
37898
|
if (court) {
|
|
37828
37899
|
court.dateAvailability = dateAvailability;
|
|
@@ -38158,6 +38229,10 @@ function modifyVenue$1({
|
|
|
38158
38229
|
return { error: INVALID_OBJECT };
|
|
38159
38230
|
if (!venueId)
|
|
38160
38231
|
return { error: MISSING_VENUE_ID };
|
|
38232
|
+
const appliedPolicies = getAppliedPolicies({
|
|
38233
|
+
tournamentRecord
|
|
38234
|
+
})?.appliedPolicies;
|
|
38235
|
+
const allowModificationWhenMatchUpsScheduled = force ?? appliedPolicies?.[POLICY_TYPE_SCHEDULING]?.allowDeletionWithScoresPresent?.venues;
|
|
38161
38236
|
const { matchUps: venueMatchUps } = getScheduledVenueMatchUps({
|
|
38162
38237
|
tournamentRecord,
|
|
38163
38238
|
venueId
|
|
@@ -38188,6 +38263,7 @@ function modifyVenue$1({
|
|
|
38188
38263
|
const courtIdsToDelete = existingCourtIds.filter(
|
|
38189
38264
|
(courtId) => !courtIdsToModify.includes(courtId)
|
|
38190
38265
|
);
|
|
38266
|
+
const matchUpsWithCourtId = [];
|
|
38191
38267
|
if (courtIdsToDelete.length) {
|
|
38192
38268
|
const courtsToDelete = venue?.courts?.filter(
|
|
38193
38269
|
(court) => courtIdsToDelete.includes(court.courtId)
|
|
@@ -38198,12 +38274,24 @@ function modifyVenue$1({
|
|
|
38198
38274
|
tournamentRecord,
|
|
38199
38275
|
venueMatchUps
|
|
38200
38276
|
});
|
|
38277
|
+
for (const matchUp of result2.matchUps ?? []) {
|
|
38278
|
+
matchUpsWithCourtId.push({
|
|
38279
|
+
matchUpId: matchUp.matchUpId,
|
|
38280
|
+
drawId: matchUp.drawId
|
|
38281
|
+
});
|
|
38282
|
+
}
|
|
38201
38283
|
return result2.matchUps?.length ?? 0;
|
|
38202
38284
|
}).reduce((a, b) => a + b);
|
|
38203
|
-
if (venue && (!scheduleDeletionsCount ||
|
|
38285
|
+
if (venue && (!scheduleDeletionsCount || allowModificationWhenMatchUpsScheduled)) {
|
|
38204
38286
|
venue.courts = venue.courts?.filter(
|
|
38205
38287
|
(court) => courtIdsToModify.includes(court.courtId)
|
|
38206
38288
|
);
|
|
38289
|
+
bulkScheduleMatchUps$1({
|
|
38290
|
+
schedule: { courtId: "", scheduledDate: "" },
|
|
38291
|
+
matchUpDetails: matchUpsWithCourtId,
|
|
38292
|
+
removePriorValues: true,
|
|
38293
|
+
tournamentRecord
|
|
38294
|
+
});
|
|
38207
38295
|
} else {
|
|
38208
38296
|
return deletionMessage({
|
|
38209
38297
|
matchUpsCount: scheduleDeletionsCount
|
|
@@ -41232,7 +41320,10 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
|
|
|
41232
41320
|
});
|
|
41233
41321
|
}
|
|
41234
41322
|
const { inContextDrawMatchUps } = addGoesTo({ drawDefinition, matchUpsMap });
|
|
41235
|
-
modifyDrawNotice({
|
|
41323
|
+
modifyDrawNotice({
|
|
41324
|
+
tournamentId: params.tournamentRecord?.tournamentId,
|
|
41325
|
+
drawDefinition
|
|
41326
|
+
});
|
|
41236
41327
|
return {
|
|
41237
41328
|
inContextDrawMatchUps,
|
|
41238
41329
|
drawDefinition,
|
|
@@ -44548,8 +44639,17 @@ function removeStructure({
|
|
|
44548
44639
|
const scoresPresent = structureMatchUps.some(
|
|
44549
44640
|
({ score }) => scoreHasValue({ score })
|
|
44550
44641
|
);
|
|
44551
|
-
if (scoresPresent
|
|
44552
|
-
|
|
44642
|
+
if (scoresPresent) {
|
|
44643
|
+
const appliedPolicies = getAppliedPolicies({
|
|
44644
|
+
tournamentRecord,
|
|
44645
|
+
drawDefinition,
|
|
44646
|
+
structure,
|
|
44647
|
+
event
|
|
44648
|
+
})?.appliedPolicies;
|
|
44649
|
+
const allowDeletionWithScoresPresent = force || appliedPolicies?.[POLICY_TYPE_SCORING]?.allowDeletionWithScoresPresent?.structures;
|
|
44650
|
+
if (!allowDeletionWithScoresPresent)
|
|
44651
|
+
return { error: SCORES_PRESENT };
|
|
44652
|
+
}
|
|
44553
44653
|
const mainStageSequence1 = structures.find(
|
|
44554
44654
|
({ stage, stageSequence }) => stage === MAIN && stageSequence === 1
|
|
44555
44655
|
);
|
|
@@ -44560,7 +44660,6 @@ function removeStructure({
|
|
|
44560
44660
|
}
|
|
44561
44661
|
const structureIds = structures.map(extractAttributes("structureId"));
|
|
44562
44662
|
const removedMatchUpIds = [];
|
|
44563
|
-
const idsToRemove = [structureId];
|
|
44564
44663
|
const getTargetedStructureIds = (structureId2) => drawDefinition.links?.map(
|
|
44565
44664
|
(link) => link.source.structureId === structureId2 && link.target.structureId !== mainStageSequence1?.structureId && link.target.structureId
|
|
44566
44665
|
).filter(Boolean) ?? [];
|
|
@@ -44575,7 +44674,8 @@ function removeStructure({
|
|
|
44575
44674
|
isQualifyingStructure ? getQualifyingSourceStructureIds(id) : getTargetedStructureIds(id)
|
|
44576
44675
|
)
|
|
44577
44676
|
);
|
|
44578
|
-
|
|
44677
|
+
const idsToRemove = isMainStageSequence1 ? relatedStructureIdsMap.get(structureId) : [structureId];
|
|
44678
|
+
while (idsToRemove?.length) {
|
|
44579
44679
|
const idBeingRemoved = idsToRemove.pop();
|
|
44580
44680
|
const { structure: structure2 } = findStructure({
|
|
44581
44681
|
structureId: idBeingRemoved,
|
|
@@ -44596,8 +44696,7 @@ function removeStructure({
|
|
|
44596
44696
|
}
|
|
44597
44697
|
);
|
|
44598
44698
|
}
|
|
44599
|
-
const targetedStructureIds = idBeingRemoved &&
|
|
44600
|
-
relatedStructureIdsMap.get(idBeingRemoved)?.filter(
|
|
44699
|
+
const targetedStructureIds = idBeingRemoved && relatedStructureIdsMap.get(idBeingRemoved)?.filter(
|
|
44601
44700
|
(id) => (
|
|
44602
44701
|
// IMPORTANT: only delete MAIN stageSequence: 1 if specified to protect against DOUBLE_ELIMINATION scenario
|
|
44603
44702
|
id !== mainStageSequence1?.structureId || structureId === mainStageSequence1.structureId
|
|
@@ -44616,6 +44715,8 @@ function removeStructure({
|
|
|
44616
44715
|
}
|
|
44617
44716
|
});
|
|
44618
44717
|
if (isMainStageSequence1) {
|
|
44718
|
+
const mainStageSequence1MatchUpIds = (mainStageSequence1.matchUps ?? [])?.map(extractAttributes("matchUpId"));
|
|
44719
|
+
removedMatchUpIds.push(...mainStageSequence1MatchUpIds);
|
|
44619
44720
|
mainStageSequence1.positionAssignments = [];
|
|
44620
44721
|
mainStageSequence1.seedAssignments = [];
|
|
44621
44722
|
mainStageSequence1.matchUps = [];
|
|
@@ -56270,23 +56371,21 @@ function getPositionAssignments({
|
|
|
56270
56371
|
};
|
|
56271
56372
|
}
|
|
56272
56373
|
|
|
56273
|
-
function deleteDrawDefinitions({
|
|
56274
|
-
|
|
56275
|
-
policyDefinitions,
|
|
56276
|
-
tournamentRecord,
|
|
56277
|
-
drawIds = [],
|
|
56278
|
-
auditData,
|
|
56279
|
-
eventId,
|
|
56280
|
-
event,
|
|
56281
|
-
force
|
|
56282
|
-
}) {
|
|
56283
|
-
if (!tournamentRecord)
|
|
56374
|
+
function deleteDrawDefinitions(params) {
|
|
56375
|
+
if (!params.tournamentRecord)
|
|
56284
56376
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
56285
56377
|
const stack = "deleteDrawDefinitions";
|
|
56286
|
-
|
|
56287
|
-
|
|
56288
|
-
|
|
56289
|
-
|
|
56378
|
+
let drawIds = params.drawIds ?? [];
|
|
56379
|
+
let event = params.event;
|
|
56380
|
+
const {
|
|
56381
|
+
autoPublish = true,
|
|
56382
|
+
tournamentRecord,
|
|
56383
|
+
auditData,
|
|
56384
|
+
eventId,
|
|
56385
|
+
force
|
|
56386
|
+
} = params;
|
|
56387
|
+
const { appliedPolicies } = getAppliedPolicies({ tournamentRecord, event });
|
|
56388
|
+
const policyDefinitions = { ...appliedPolicies, ...params.policyDefinitions };
|
|
56290
56389
|
const drawId = Array.isArray(drawIds) ? drawIds[0] : void 0;
|
|
56291
56390
|
if (!event) {
|
|
56292
56391
|
const result = findEvent({ tournamentRecord, eventId, drawId });
|
|
@@ -56324,6 +56423,7 @@ function deleteDrawDefinitions({
|
|
|
56324
56423
|
qualifier,
|
|
56325
56424
|
bye
|
|
56326
56425
|
}) => ({ bye, qualifier, drawPosition, participantId });
|
|
56426
|
+
const allowDeletionWithScoresPresent = force || appliedPolicies?.[POLICY_TYPE_SCORING]?.allowDeletionWithScoresPresent?.drawDefinitions;
|
|
56327
56427
|
const drawIdsWithScoresPresent = [];
|
|
56328
56428
|
const filteredDrawDefinitions = event.drawDefinitions.filter(
|
|
56329
56429
|
(drawDefinition) => {
|
|
@@ -56332,7 +56432,7 @@ function deleteDrawDefinitions({
|
|
|
56332
56432
|
const scoresPresent = matchUps.some(
|
|
56333
56433
|
({ score }) => scoreHasValue({ score })
|
|
56334
56434
|
);
|
|
56335
|
-
if (scoresPresent && !
|
|
56435
|
+
if (scoresPresent && !allowDeletionWithScoresPresent) {
|
|
56336
56436
|
drawIdsWithScoresPresent.push(drawDefinition.drawId);
|
|
56337
56437
|
return true;
|
|
56338
56438
|
}
|
|
@@ -58100,7 +58200,8 @@ function deleteFlightProfileAndFlightDraws({
|
|
|
58100
58200
|
autoPublish = true,
|
|
58101
58201
|
tournamentRecord,
|
|
58102
58202
|
auditData,
|
|
58103
|
-
event
|
|
58203
|
+
event,
|
|
58204
|
+
force
|
|
58104
58205
|
}) {
|
|
58105
58206
|
if (!tournamentRecord)
|
|
58106
58207
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
@@ -58115,7 +58216,8 @@ function deleteFlightProfileAndFlightDraws({
|
|
|
58115
58216
|
autoPublish,
|
|
58116
58217
|
auditData,
|
|
58117
58218
|
drawIds,
|
|
58118
|
-
event
|
|
58219
|
+
event,
|
|
58220
|
+
force
|
|
58119
58221
|
});
|
|
58120
58222
|
if (result.error)
|
|
58121
58223
|
return result;
|
|
@@ -64822,6 +64924,7 @@ function modifyTournamentRecord(params) {
|
|
|
64822
64924
|
schedulingProfile,
|
|
64823
64925
|
tournamentRecord,
|
|
64824
64926
|
eventProfiles,
|
|
64927
|
+
periodLength,
|
|
64825
64928
|
venueProfiles,
|
|
64826
64929
|
autoSchedule,
|
|
64827
64930
|
drawProfiles,
|
|
@@ -64997,7 +65100,10 @@ function modifyTournamentRecord(params) {
|
|
|
64997
65100
|
if (autoSchedule) {
|
|
64998
65101
|
const { tournamentId } = tournamentRecord;
|
|
64999
65102
|
const tournamentRecords2 = { [tournamentId]: tournamentRecord };
|
|
65000
|
-
schedulerResult = scheduleProfileRounds({
|
|
65103
|
+
schedulerResult = scheduleProfileRounds({
|
|
65104
|
+
tournamentRecords: tournamentRecords2,
|
|
65105
|
+
periodLength
|
|
65106
|
+
});
|
|
65001
65107
|
}
|
|
65002
65108
|
}
|
|
65003
65109
|
const totalParticipantsCount = tournamentRecord.participants.length;
|
|
@@ -65101,6 +65207,7 @@ function generateTournamentRecord(params) {
|
|
|
65101
65207
|
randomWinningSide,
|
|
65102
65208
|
policyDefinitions,
|
|
65103
65209
|
schedulingProfile,
|
|
65210
|
+
periodLength,
|
|
65104
65211
|
autoSchedule,
|
|
65105
65212
|
eventProfiles,
|
|
65106
65213
|
venueProfiles,
|
|
@@ -65241,7 +65348,8 @@ function generateTournamentRecord(params) {
|
|
|
65241
65348
|
const tournamentRecords = { [tournamentId]: tournamentRecord };
|
|
65242
65349
|
schedulerResult = scheduleProfileRounds({
|
|
65243
65350
|
scheduleCompletedMatchUps,
|
|
65244
|
-
tournamentRecords
|
|
65351
|
+
tournamentRecords,
|
|
65352
|
+
periodLength
|
|
65245
65353
|
});
|
|
65246
65354
|
}
|
|
65247
65355
|
}
|