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
|
@@ -2929,7 +2929,7 @@ var matchUpFormatCode = {
|
|
|
2929
2929
|
};
|
|
2930
2930
|
|
|
2931
2931
|
function factoryVersion() {
|
|
2932
|
-
return '1.8.
|
|
2932
|
+
return '1.8.42';
|
|
2933
2933
|
}
|
|
2934
2934
|
|
|
2935
2935
|
function getObjectTieFormat(obj) {
|
|
@@ -16856,11 +16856,12 @@ var _a$9, _b$4, _c, _d, _e;
|
|
|
16856
16856
|
var ADULT = 'ADULT';
|
|
16857
16857
|
var JUNIOR = 'JUNIOR';
|
|
16858
16858
|
var WHEELCHAIR = 'WHEELCHAIR';
|
|
16859
|
-
/**
|
|
16860
|
-
*
|
|
16861
|
-
*/
|
|
16862
16859
|
var POLICY_SCHEDULING_DEFAULT = (_a$9 = {},
|
|
16863
16860
|
_a$9[POLICY_TYPE_SCHEDULING] = {
|
|
16861
|
+
allowModificationWhenMatchUpsScheduled: {
|
|
16862
|
+
courts: false,
|
|
16863
|
+
venues: false,
|
|
16864
|
+
},
|
|
16864
16865
|
defaultTimes: {
|
|
16865
16866
|
averageTimes: [{ categoryNames: [], minutes: { default: 90 } }],
|
|
16866
16867
|
recoveryTimes: [{ minutes: (_b$4 = {}, _b$4[DOUBLES$1] = 30, _b$4.default = 60, _b$4) }],
|
|
@@ -17137,6 +17138,10 @@ var _a$7, _b$2;
|
|
|
17137
17138
|
var POLICY_SCORING_DEFAULT = (_a$7 = {},
|
|
17138
17139
|
_a$7[POLICY_TYPE_SCORING] = {
|
|
17139
17140
|
defaultMatchUpFormat: FORMAT_STANDARD,
|
|
17141
|
+
allowDeletionWithScoresPresent: {
|
|
17142
|
+
drawDefinitions: false,
|
|
17143
|
+
structures: false,
|
|
17144
|
+
},
|
|
17140
17145
|
requireAllPositionsAssigned: false,
|
|
17141
17146
|
processCodes: {
|
|
17142
17147
|
incompleteAssignmentsOnDefault: ['RANKING.IGNORE'],
|
|
@@ -22848,7 +22853,7 @@ function getDrawDefinition$1(_a) {
|
|
|
22848
22853
|
function bulkScheduleMatchUps$1(_a) {
|
|
22849
22854
|
var e_1, _b, e_2, _c;
|
|
22850
22855
|
var _d, _e, _f, _g;
|
|
22851
|
-
var _h = _a.scheduleCompletedMatchUps, scheduleCompletedMatchUps = _h === void 0 ? false : _h, _j = _a.scheduleByeMatchUps, scheduleByeMatchUps = _j === void 0 ? false : _j, _k = _a.errorOnAnachronism, errorOnAnachronism = _k === void 0 ? false : _k, _l = _a.checkChronology, checkChronology = _l === void 0 ? true : _l, matchUpDependencies = _a.matchUpDependencies, tournamentRecords = _a.tournamentRecords, tournamentRecord = _a.tournamentRecord, matchUpDetails = _a.matchUpDetails, matchUpIds = _a.matchUpIds, schedule = _a.schedule;
|
|
22856
|
+
var _h = _a.scheduleCompletedMatchUps, scheduleCompletedMatchUps = _h === void 0 ? false : _h, _j = _a.scheduleByeMatchUps, scheduleByeMatchUps = _j === void 0 ? false : _j, _k = _a.errorOnAnachronism, errorOnAnachronism = _k === void 0 ? false : _k, _l = _a.checkChronology, checkChronology = _l === void 0 ? true : _l, matchUpDependencies = _a.matchUpDependencies, removePriorValues = _a.removePriorValues, tournamentRecords = _a.tournamentRecords, tournamentRecord = _a.tournamentRecord, matchUpDetails = _a.matchUpDetails, matchUpIds = _a.matchUpIds, schedule = _a.schedule;
|
|
22852
22857
|
if (!tournamentRecord)
|
|
22853
22858
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
22854
22859
|
if (!matchUpDetails && (!matchUpIds || !Array.isArray(matchUpIds)))
|
|
@@ -22861,7 +22866,10 @@ function bulkScheduleMatchUps$1(_a) {
|
|
|
22861
22866
|
// Optimize getting matchUps for all tournamentRecords
|
|
22862
22867
|
// if matchUpDependencies are provided, skip this step
|
|
22863
22868
|
if (checkChronology && !matchUpDependencies) {
|
|
22864
|
-
var result = getMatchUpDependencies({
|
|
22869
|
+
var result = getMatchUpDependencies({
|
|
22870
|
+
tournamentRecords: tournamentRecords,
|
|
22871
|
+
tournamentRecord: tournamentRecord,
|
|
22872
|
+
});
|
|
22865
22873
|
matchUpDependencies = result.matchUpDependencies;
|
|
22866
22874
|
inContextMatchUps = result.matchUps;
|
|
22867
22875
|
}
|
|
@@ -22910,6 +22918,7 @@ function bulkScheduleMatchUps$1(_a) {
|
|
|
22910
22918
|
schedule: matchUpSchedule,
|
|
22911
22919
|
matchUpDependencies: matchUpDependencies,
|
|
22912
22920
|
errorOnAnachronism: errorOnAnachronism,
|
|
22921
|
+
removePriorValues: removePriorValues,
|
|
22913
22922
|
inContextMatchUps: inContextMatchUps,
|
|
22914
22923
|
tournamentRecords: tournamentRecords,
|
|
22915
22924
|
tournamentRecord: tournamentRecord,
|
|
@@ -22956,7 +22965,7 @@ function bulkScheduleMatchUps$1(_a) {
|
|
|
22956
22965
|
function bulkScheduleMatchUps(_a) {
|
|
22957
22966
|
var e_1, _b;
|
|
22958
22967
|
var _c;
|
|
22959
|
-
var _d = _a.scheduleCompletedMatchUps, scheduleCompletedMatchUps = _d === void 0 ? false : _d, _e = _a.scheduleByeMatchUps, scheduleByeMatchUps = _e === void 0 ? false : _e, errorOnAnachronism = _a.errorOnAnachronism, matchUpContextIds = _a.matchUpContextIds, tournamentRecords = _a.tournamentRecords, checkChronology = _a.checkChronology, matchUpDetails = _a.matchUpDetails, schedule = _a.schedule;
|
|
22968
|
+
var _d = _a.scheduleCompletedMatchUps, scheduleCompletedMatchUps = _d === void 0 ? false : _d, _e = _a.scheduleByeMatchUps, scheduleByeMatchUps = _e === void 0 ? false : _e, errorOnAnachronism = _a.errorOnAnachronism, matchUpContextIds = _a.matchUpContextIds, removePriorValues = _a.removePriorValues, tournamentRecords = _a.tournamentRecords, checkChronology = _a.checkChronology, matchUpDetails = _a.matchUpDetails, schedule = _a.schedule;
|
|
22960
22969
|
if (!tournamentRecords)
|
|
22961
22970
|
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
22962
22971
|
if (!Array.isArray(matchUpContextIds) && !Array.isArray(matchUpDetails))
|
|
@@ -22979,6 +22988,7 @@ function bulkScheduleMatchUps(_a) {
|
|
|
22979
22988
|
scheduleByeMatchUps: scheduleByeMatchUps,
|
|
22980
22989
|
matchUpDependencies: matchUpDependencies,
|
|
22981
22990
|
errorOnAnachronism: errorOnAnachronism,
|
|
22991
|
+
removePriorValues: removePriorValues,
|
|
22982
22992
|
tournamentRecords: tournamentRecords,
|
|
22983
22993
|
tournamentRecord: tournamentRecord,
|
|
22984
22994
|
checkChronology: checkChronology,
|
|
@@ -35255,13 +35265,16 @@ function processAlreadyScheduledMatchUps(_a) {
|
|
|
35255
35265
|
var e_1, _b;
|
|
35256
35266
|
var _c, _d;
|
|
35257
35267
|
var matchUpPotentialParticipantIds = _a.matchUpPotentialParticipantIds, individualParticipantProfiles = _a.individualParticipantProfiles, dateScheduledMatchUpIds = _a.dateScheduledMatchUpIds, greatestAverageMinutes = _a.greatestAverageMinutes, dateScheduledMatchUps = _a.dateScheduledMatchUps, matchUpNotBeforeTimes = _a.matchUpNotBeforeTimes, matchUpScheduleTimes = _a.matchUpScheduleTimes, matchUpDependencies = _a.matchUpDependencies, clearScheduleDates = _a.clearScheduleDates, scheduleDate = _a.scheduleDate, minutesMap = _a.minutesMap, matchUps = _a.matchUps;
|
|
35258
|
-
var
|
|
35268
|
+
var byeScheduledMatchUpDetails = [];
|
|
35259
35269
|
if (!dateScheduledMatchUpIds) {
|
|
35260
35270
|
dateScheduledMatchUps = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(function (matchUp) {
|
|
35261
35271
|
var schedule = matchUp.schedule || {};
|
|
35262
35272
|
var isByeMatchUp = matchUp.matchUpStatus === BYE;
|
|
35263
35273
|
if (isByeMatchUp)
|
|
35264
|
-
|
|
35274
|
+
byeScheduledMatchUpDetails.push({
|
|
35275
|
+
tournamentId: matchUp.tournamentId,
|
|
35276
|
+
matchUpId: matchUp.matchUpId,
|
|
35277
|
+
});
|
|
35265
35278
|
return (!isByeMatchUp &&
|
|
35266
35279
|
hasSchedule({ schedule: schedule }) &&
|
|
35267
35280
|
(!scheduleDate || matchUp.schedule.scheduledDate === scheduleDate));
|
|
@@ -35316,7 +35329,7 @@ function processAlreadyScheduledMatchUps(_a) {
|
|
|
35316
35329
|
}
|
|
35317
35330
|
return {
|
|
35318
35331
|
dateScheduledMatchUpIds: dateScheduledMatchUpIds,
|
|
35319
|
-
|
|
35332
|
+
byeScheduledMatchUpDetails: byeScheduledMatchUpDetails,
|
|
35320
35333
|
dateScheduledMatchUps: dateScheduledMatchUps,
|
|
35321
35334
|
clearDate: clearDate,
|
|
35322
35335
|
};
|
|
@@ -35368,10 +35381,10 @@ function getGroupedRounds(_a) {
|
|
|
35368
35381
|
}
|
|
35369
35382
|
if (groupedMatchUpIds.length) {
|
|
35370
35383
|
groupedRounds.push({
|
|
35371
|
-
averageMinutes: averageMinutes,
|
|
35372
|
-
recoveryMinutes: recoveryMinutes,
|
|
35373
|
-
roundPeriodLength: roundPeriodLength,
|
|
35374
35384
|
matchUpIds: groupedMatchUpIds,
|
|
35385
|
+
roundPeriodLength: roundPeriodLength,
|
|
35386
|
+
recoveryMinutes: recoveryMinutes,
|
|
35387
|
+
averageMinutes: averageMinutes,
|
|
35375
35388
|
});
|
|
35376
35389
|
}
|
|
35377
35390
|
return { groupedRounds: groupedRounds };
|
|
@@ -35560,7 +35573,7 @@ function getVenueSchedulingDetails(_a) {
|
|
|
35560
35573
|
var venueScheduledRoundDetails = {};
|
|
35561
35574
|
// checking that matchUpDependencies is scoped to only those matchUps that are already or are to be scheduled on the same date
|
|
35562
35575
|
var allDateScheduledMatchUpIds = [];
|
|
35563
|
-
var
|
|
35576
|
+
var allDateScheduledByeMatchUpDetails = [];
|
|
35564
35577
|
var allDateMatchUpIds = [];
|
|
35565
35578
|
var _loop_1 = function (venue) {
|
|
35566
35579
|
var _d;
|
|
@@ -35610,9 +35623,9 @@ function getVenueSchedulingDetails(_a) {
|
|
|
35610
35623
|
matchUps: matchUps,
|
|
35611
35624
|
});
|
|
35612
35625
|
(dateScheduledMatchUpIds = processResult.dateScheduledMatchUpIds, dateScheduledMatchUps = processResult.dateScheduledMatchUps);
|
|
35613
|
-
var
|
|
35614
|
-
if (
|
|
35615
|
-
|
|
35626
|
+
var byeScheduledMatchUpDetails = processResult.byeScheduledMatchUpDetails, clearDate = processResult.clearDate;
|
|
35627
|
+
if (byeScheduledMatchUpDetails === null || byeScheduledMatchUpDetails === void 0 ? void 0 : byeScheduledMatchUpDetails.length)
|
|
35628
|
+
allDateScheduledByeMatchUpDetails.push.apply(allDateScheduledByeMatchUpDetails, __spreadArray([], __read(byeScheduledMatchUpDetails), false));
|
|
35616
35629
|
var _g = getMatchUpsToSchedule({
|
|
35617
35630
|
matchUpPotentialParticipantIds: matchUpPotentialParticipantIds,
|
|
35618
35631
|
scheduleCompletedMatchUps: scheduleCompletedMatchUps,
|
|
@@ -35656,7 +35669,7 @@ function getVenueSchedulingDetails(_a) {
|
|
|
35656
35669
|
finally { if (e_1) throw e_1.error; }
|
|
35657
35670
|
}
|
|
35658
35671
|
return {
|
|
35659
|
-
|
|
35672
|
+
allDateScheduledByeMatchUpDetails: allDateScheduledByeMatchUpDetails,
|
|
35660
35673
|
allDateScheduledMatchUpIds: allDateScheduledMatchUpIds,
|
|
35661
35674
|
venueScheduledRoundDetails: venueScheduledRoundDetails,
|
|
35662
35675
|
allDateMatchUpIds: allDateMatchUpIds,
|
|
@@ -35821,7 +35834,7 @@ function jinnScheduler(_a) {
|
|
|
35821
35834
|
var e_1, _b;
|
|
35822
35835
|
var _c, _d, _e, _f, _g, _h, _j;
|
|
35823
35836
|
var schedulingProfileModifications = _a.schedulingProfileModifications, checkPotentialRequestConflicts = _a.checkPotentialRequestConflicts, scheduleCompletedMatchUps = _a.scheduleCompletedMatchUps, // override which can be used by mocksEngine
|
|
35824
|
-
schedulingProfileIssues = _a.schedulingProfileIssues, dateSchedulingProfiles = _a.dateSchedulingProfiles, containedStructureIds = _a.containedStructureIds, matchUpDependencies = _a.matchUpDependencies, matchUpDailyLimits = _a.matchUpDailyLimits, clearScheduleDates = _a.clearScheduleDates,
|
|
35837
|
+
schedulingProfileIssues = _a.schedulingProfileIssues, dateSchedulingProfiles = _a.dateSchedulingProfiles, containedStructureIds = _a.containedStructureIds, matchUpDependencies = _a.matchUpDependencies, matchUpDailyLimits = _a.matchUpDailyLimits, clearScheduleDates = _a.clearScheduleDates, tournamentRecords = _a.tournamentRecords, schedulingProfile = _a.schedulingProfile, personRequests = _a.personRequests, periodLength = _a.periodLength, matchUps = _a.matchUps, courts = _a.courts, dryRun = _a.dryRun;
|
|
35825
35838
|
var scheduleTimesRemaining = {};
|
|
35826
35839
|
var skippedScheduleTimes = {};
|
|
35827
35840
|
var recoveryTimeDeferredMatchUpIds = {};
|
|
@@ -35888,7 +35901,7 @@ function jinnScheduler(_a) {
|
|
|
35888
35901
|
matchUps: matchUps,
|
|
35889
35902
|
courts: courts,
|
|
35890
35903
|
venues: venues,
|
|
35891
|
-
}), venueScheduledRoundDetails = _p.venueScheduledRoundDetails, allDateMatchUpIds = _p.allDateMatchUpIds;
|
|
35904
|
+
}), allDateScheduledByeMatchUpDetails = _p.allDateScheduledByeMatchUpDetails, venueScheduledRoundDetails = _p.venueScheduledRoundDetails, allDateMatchUpIds = _p.allDateMatchUpIds;
|
|
35892
35905
|
var maxScheduleTimeAttempts = 10; // TODO: calculate this based on max court start/end range and averageMinutes
|
|
35893
35906
|
var schedulingIterations = 0;
|
|
35894
35907
|
var schedulingComplete = void 0;
|
|
@@ -36116,6 +36129,23 @@ function jinnScheduler(_a) {
|
|
|
36116
36129
|
}
|
|
36117
36130
|
finally { if (e_3) throw e_3.error; }
|
|
36118
36131
|
}
|
|
36132
|
+
if (!dryRun && (allDateScheduledByeMatchUpDetails === null || allDateScheduledByeMatchUpDetails === void 0 ? void 0 : allDateScheduledByeMatchUpDetails.length)) {
|
|
36133
|
+
// remove scheduling information for BYE matchUps from any rounds that were scheduled
|
|
36134
|
+
// remove scheduling information for BYE matchUps from any rounds that were scheduled
|
|
36135
|
+
bulkScheduleMatchUps({
|
|
36136
|
+
matchUpDetails: allDateScheduledByeMatchUpDetails,
|
|
36137
|
+
scheduleByeMatchUps: true,
|
|
36138
|
+
removePriorValues: true,
|
|
36139
|
+
tournamentRecords: tournamentRecords,
|
|
36140
|
+
schedule: {
|
|
36141
|
+
scheduledDate: '',
|
|
36142
|
+
scheduledTime: '',
|
|
36143
|
+
courtOrder: '',
|
|
36144
|
+
courtId: '',
|
|
36145
|
+
venueId: '',
|
|
36146
|
+
},
|
|
36147
|
+
});
|
|
36148
|
+
}
|
|
36119
36149
|
try {
|
|
36120
36150
|
for (var _q = (e_4 = void 0, __values(dateSchedulingProfile.venues)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
36121
36151
|
var venue = _r.value;
|
|
@@ -36187,6 +36217,285 @@ function jinnScheduler(_a) {
|
|
|
36187
36217
|
return __assign(__assign({}, SUCCESS), { schedulingProfileModifications: schedulingProfileModifications, schedulingProfileIssues: schedulingProfileIssues, scheduleTimesRemaining: scheduleTimesRemaining, dateSchedulingProfiles: dateSchedulingProfiles, skippedScheduleTimes: skippedScheduleTimes, recoveryTimeDeferredMatchUpIds: recoveryTimeDeferredMatchUpIds, dependencyDeferredMatchUpIds: dependencyDeferredMatchUpIds, matchUpScheduleTimes: matchUpScheduleTimes, overLimitMatchUpIds: overLimitMatchUpIds, scheduledMatchUpIds: scheduledMatchUpIds, noTimeMatchUpIds: noTimeMatchUpIds, requestConflicts: requestConflicts, scheduledDates: scheduledDates });
|
|
36188
36218
|
}
|
|
36189
36219
|
|
|
36220
|
+
function getPersonRequests(_a) {
|
|
36221
|
+
var e_1, _b, e_2, _c, e_3, _d;
|
|
36222
|
+
var tournamentRecords = _a.tournamentRecords, requestType = _a.requestType;
|
|
36223
|
+
if (typeof tournamentRecords !== 'object' ||
|
|
36224
|
+
!Object.keys(tournamentRecords).length)
|
|
36225
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36226
|
+
var personRequests = {};
|
|
36227
|
+
try {
|
|
36228
|
+
// create merged view of person requests across tournamentRecords
|
|
36229
|
+
// ... possible for a person to be in multiple linked tournamentRecords
|
|
36230
|
+
for (var _e = __values(Object.values(tournamentRecords)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
36231
|
+
var tournamentRecord = _f.value;
|
|
36232
|
+
var extension = findTournamentExtension({
|
|
36233
|
+
name: PERSON_REQUESTS,
|
|
36234
|
+
tournamentRecord: tournamentRecord,
|
|
36235
|
+
}).extension;
|
|
36236
|
+
var requestObjects = (extension === null || extension === void 0 ? void 0 : extension.value) || [];
|
|
36237
|
+
try {
|
|
36238
|
+
for (var requestObjects_1 = (e_2 = void 0, __values(requestObjects)), requestObjects_1_1 = requestObjects_1.next(); !requestObjects_1_1.done; requestObjects_1_1 = requestObjects_1.next()) {
|
|
36239
|
+
var requestObject = requestObjects_1_1.value;
|
|
36240
|
+
var _g = requestObject || {}, personId = _g.personId, requests = _g.requests;
|
|
36241
|
+
if (!personRequests[personId])
|
|
36242
|
+
personRequests[personId] = [];
|
|
36243
|
+
try {
|
|
36244
|
+
for (var requests_1 = (e_3 = void 0, __values(requests)), requests_1_1 = requests_1.next(); !requests_1_1.done; requests_1_1 = requests_1.next()) {
|
|
36245
|
+
var request = requests_1_1.value;
|
|
36246
|
+
if (requestType && request.requestType !== requestType)
|
|
36247
|
+
continue;
|
|
36248
|
+
personRequests[personId].push(request);
|
|
36249
|
+
}
|
|
36250
|
+
}
|
|
36251
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
36252
|
+
finally {
|
|
36253
|
+
try {
|
|
36254
|
+
if (requests_1_1 && !requests_1_1.done && (_d = requests_1.return)) _d.call(requests_1);
|
|
36255
|
+
}
|
|
36256
|
+
finally { if (e_3) throw e_3.error; }
|
|
36257
|
+
}
|
|
36258
|
+
}
|
|
36259
|
+
}
|
|
36260
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
36261
|
+
finally {
|
|
36262
|
+
try {
|
|
36263
|
+
if (requestObjects_1_1 && !requestObjects_1_1.done && (_c = requestObjects_1.return)) _c.call(requestObjects_1);
|
|
36264
|
+
}
|
|
36265
|
+
finally { if (e_2) throw e_2.error; }
|
|
36266
|
+
}
|
|
36267
|
+
}
|
|
36268
|
+
}
|
|
36269
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36270
|
+
finally {
|
|
36271
|
+
try {
|
|
36272
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
36273
|
+
}
|
|
36274
|
+
finally { if (e_1) throw e_1.error; }
|
|
36275
|
+
}
|
|
36276
|
+
// audit requests and filter out any that are no longer relevant
|
|
36277
|
+
// (tournament dates changed & etc)
|
|
36278
|
+
return { personRequests: personRequests };
|
|
36279
|
+
}
|
|
36280
|
+
function savePersonRequests(_a) {
|
|
36281
|
+
var e_4, _b, e_5, _c;
|
|
36282
|
+
var _d;
|
|
36283
|
+
var tournamentRecords = _a.tournamentRecords, personRequests = _a.personRequests;
|
|
36284
|
+
if (!tournamentRecords)
|
|
36285
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36286
|
+
if (!personRequests)
|
|
36287
|
+
return __assign({}, SUCCESS);
|
|
36288
|
+
var tournaments = Object.values(tournamentRecords);
|
|
36289
|
+
try {
|
|
36290
|
+
for (var tournaments_1 = __values(tournaments), tournaments_1_1 = tournaments_1.next(); !tournaments_1_1.done; tournaments_1_1 = tournaments_1.next()) {
|
|
36291
|
+
var tournamentRecord = tournaments_1_1.value;
|
|
36292
|
+
var tournamentParticipants = (_d = tournamentRecord.participants) !== null && _d !== void 0 ? _d : [];
|
|
36293
|
+
var relevantPersonRequests = [];
|
|
36294
|
+
try {
|
|
36295
|
+
for (var _e = (e_5 = void 0, __values(Object.keys(personRequests))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
36296
|
+
var personId = _f.value;
|
|
36297
|
+
if (findParticipant({ tournamentParticipants: tournamentParticipants, personId: personId })) {
|
|
36298
|
+
var requests = personRequests[personId];
|
|
36299
|
+
if (requests.length)
|
|
36300
|
+
relevantPersonRequests.push({ personId: personId, requests: requests });
|
|
36301
|
+
}
|
|
36302
|
+
}
|
|
36303
|
+
}
|
|
36304
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
36305
|
+
finally {
|
|
36306
|
+
try {
|
|
36307
|
+
if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
|
|
36308
|
+
}
|
|
36309
|
+
finally { if (e_5) throw e_5.error; }
|
|
36310
|
+
}
|
|
36311
|
+
if (Object.keys(relevantPersonRequests).length) {
|
|
36312
|
+
var extension = {
|
|
36313
|
+
name: PERSON_REQUESTS,
|
|
36314
|
+
value: relevantPersonRequests,
|
|
36315
|
+
};
|
|
36316
|
+
addTournamentExtension({ tournamentRecord: tournamentRecord, extension: extension });
|
|
36317
|
+
}
|
|
36318
|
+
}
|
|
36319
|
+
}
|
|
36320
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
36321
|
+
finally {
|
|
36322
|
+
try {
|
|
36323
|
+
if (tournaments_1_1 && !tournaments_1_1.done && (_b = tournaments_1.return)) _b.call(tournaments_1);
|
|
36324
|
+
}
|
|
36325
|
+
finally { if (e_4) throw e_4.error; }
|
|
36326
|
+
}
|
|
36327
|
+
return __assign({}, SUCCESS);
|
|
36328
|
+
}
|
|
36329
|
+
function addPersonRequests(_a) {
|
|
36330
|
+
var tournamentRecords = _a.tournamentRecords, personId = _a.personId, requests = _a.requests;
|
|
36331
|
+
if (!tournamentRecords)
|
|
36332
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36333
|
+
if (typeof personId !== 'string')
|
|
36334
|
+
return { error: INVALID_VALUES };
|
|
36335
|
+
if (!Array.isArray(requests))
|
|
36336
|
+
return { error: INVALID_VALUES };
|
|
36337
|
+
var personRequests = getPersonRequests({ tournamentRecords: tournamentRecords }).personRequests;
|
|
36338
|
+
var mergeCount = mergePersonRequests({
|
|
36339
|
+
personRequests: personRequests,
|
|
36340
|
+
personId: personId,
|
|
36341
|
+
requests: requests,
|
|
36342
|
+
}).mergeCount;
|
|
36343
|
+
if (mergeCount && personRequests) {
|
|
36344
|
+
return savePersonRequests({ tournamentRecords: tournamentRecords, personRequests: personRequests });
|
|
36345
|
+
}
|
|
36346
|
+
else {
|
|
36347
|
+
return { error: INVALID_VALUES };
|
|
36348
|
+
}
|
|
36349
|
+
}
|
|
36350
|
+
// check whether there is a request for the date with overlapping times
|
|
36351
|
+
// extend startTime/endTime rather than creating multiple
|
|
36352
|
+
// ... only pertains to { requestType: DO_NOT_SCHEDULE }
|
|
36353
|
+
function mergePersonRequests(_a) {
|
|
36354
|
+
var e_6, _b;
|
|
36355
|
+
var personRequests = _a.personRequests, personId = _a.personId, requests = _a.requests;
|
|
36356
|
+
if (!personRequests[personId])
|
|
36357
|
+
personRequests[personId] = [];
|
|
36358
|
+
var filteredRequests = requests
|
|
36359
|
+
.filter(function (_a) {
|
|
36360
|
+
var requestType = _a.requestType;
|
|
36361
|
+
return requestType;
|
|
36362
|
+
})
|
|
36363
|
+
.map(function (request) {
|
|
36364
|
+
var date = request.date, startTime = request.startTime, endTime = request.endTime;
|
|
36365
|
+
// validate requestType
|
|
36366
|
+
if (request.requestType === DO_NOT_SCHEDULE) {
|
|
36367
|
+
date = extractDate(date);
|
|
36368
|
+
startTime = extractTime(startTime);
|
|
36369
|
+
endTime = extractTime(endTime);
|
|
36370
|
+
if (date && startTime && endTime) {
|
|
36371
|
+
return { date: date, startTime: startTime, endTime: endTime, requestType: request.requestType };
|
|
36372
|
+
}
|
|
36373
|
+
}
|
|
36374
|
+
return request;
|
|
36375
|
+
})
|
|
36376
|
+
.filter(Boolean);
|
|
36377
|
+
try {
|
|
36378
|
+
// Do not add any request that is missing requestType
|
|
36379
|
+
for (var filteredRequests_1 = __values(filteredRequests), filteredRequests_1_1 = filteredRequests_1.next(); !filteredRequests_1_1.done; filteredRequests_1_1 = filteredRequests_1.next()) {
|
|
36380
|
+
var request = filteredRequests_1_1.value;
|
|
36381
|
+
request.requestId = generateTimeCode();
|
|
36382
|
+
personRequests[personId].push(request);
|
|
36383
|
+
}
|
|
36384
|
+
}
|
|
36385
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
36386
|
+
finally {
|
|
36387
|
+
try {
|
|
36388
|
+
if (filteredRequests_1_1 && !filteredRequests_1_1.done && (_b = filteredRequests_1.return)) _b.call(filteredRequests_1);
|
|
36389
|
+
}
|
|
36390
|
+
finally { if (e_6) throw e_6.error; }
|
|
36391
|
+
}
|
|
36392
|
+
return { mergeCount: filteredRequests.length };
|
|
36393
|
+
}
|
|
36394
|
+
// personRequests can be removed by date, requestId, or requestType
|
|
36395
|
+
function removePersonRequests(_a) {
|
|
36396
|
+
var e_7, _b;
|
|
36397
|
+
var tournamentRecords = _a.tournamentRecords, requestType = _a.requestType, requestId = _a.requestId, personId = _a.personId, date = _a.date;
|
|
36398
|
+
if (typeof tournamentRecords !== 'object' ||
|
|
36399
|
+
!Object.keys(tournamentRecords).length)
|
|
36400
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36401
|
+
var personRequests = getPersonRequests({ tournamentRecords: tournamentRecords }).personRequests;
|
|
36402
|
+
var filterRequests = function (personId) {
|
|
36403
|
+
var _a;
|
|
36404
|
+
if (personRequests) {
|
|
36405
|
+
personRequests[personId] = personRequests[personId].filter(function (request) {
|
|
36406
|
+
return ((!requestType || request.requestType !== requestType) &&
|
|
36407
|
+
(!requestId || request.requestId !== requestId) &&
|
|
36408
|
+
(!date || request.date !== date));
|
|
36409
|
+
});
|
|
36410
|
+
if (!((_a = personRequests === null || personRequests === void 0 ? void 0 : personRequests[personId]) === null || _a === void 0 ? void 0 : _a.length))
|
|
36411
|
+
delete personRequests[personId];
|
|
36412
|
+
}
|
|
36413
|
+
};
|
|
36414
|
+
var removeAll = !requestType && !requestId && !personId && !date;
|
|
36415
|
+
if (!removeAll) {
|
|
36416
|
+
if (personId && (personRequests === null || personRequests === void 0 ? void 0 : personRequests[personId])) {
|
|
36417
|
+
filterRequests(personId);
|
|
36418
|
+
}
|
|
36419
|
+
else if (personRequests) {
|
|
36420
|
+
try {
|
|
36421
|
+
for (var _c = __values(Object.keys(personRequests)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
36422
|
+
var personId_1 = _d.value;
|
|
36423
|
+
filterRequests(personId_1);
|
|
36424
|
+
}
|
|
36425
|
+
}
|
|
36426
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
36427
|
+
finally {
|
|
36428
|
+
try {
|
|
36429
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
36430
|
+
}
|
|
36431
|
+
finally { if (e_7) throw e_7.error; }
|
|
36432
|
+
}
|
|
36433
|
+
}
|
|
36434
|
+
}
|
|
36435
|
+
if (removeAll || !personRequests || !Object.keys(personRequests).length) {
|
|
36436
|
+
return removeExtension({ tournamentRecords: tournamentRecords, name: PERSON_REQUESTS });
|
|
36437
|
+
}
|
|
36438
|
+
else {
|
|
36439
|
+
return savePersonRequests({ tournamentRecords: tournamentRecords, personRequests: personRequests });
|
|
36440
|
+
}
|
|
36441
|
+
}
|
|
36442
|
+
// can be used to both add and remove requests
|
|
36443
|
+
// requests which don't have existing requestId will be added
|
|
36444
|
+
// requests which don't have requestType will be removed
|
|
36445
|
+
function modifyPersonRequests(_a) {
|
|
36446
|
+
var e_8, _b;
|
|
36447
|
+
var tournamentRecords = _a.tournamentRecords, requests = _a.requests, personId = _a.personId;
|
|
36448
|
+
if (!tournamentRecords)
|
|
36449
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36450
|
+
if (!Array.isArray(requests))
|
|
36451
|
+
return { error: INVALID_VALUES };
|
|
36452
|
+
var requestIds = requests.map(function (_a) {
|
|
36453
|
+
var requestId = _a.requestId;
|
|
36454
|
+
return requestId;
|
|
36455
|
+
}).filter(Boolean);
|
|
36456
|
+
var personRequests = getPersonRequests({ tournamentRecords: tournamentRecords }).personRequests;
|
|
36457
|
+
var modifyRequests = function (personId) {
|
|
36458
|
+
if (personRequests) {
|
|
36459
|
+
personRequests[personId] = personRequests[personId]
|
|
36460
|
+
.map(function (request) {
|
|
36461
|
+
// if requestId not in requestIds then return unmodified
|
|
36462
|
+
if (!requestIds.includes(request.requestId))
|
|
36463
|
+
return request;
|
|
36464
|
+
// find the updatedRequest
|
|
36465
|
+
var modification = requests.find(function (updatedRequest) { return updatedRequest.requestId === request.requestId; });
|
|
36466
|
+
// FEATURE: returning an updatedRequest without a requestType will remove it
|
|
36467
|
+
if (!modification.requestType)
|
|
36468
|
+
return;
|
|
36469
|
+
return Object.assign(request, modification);
|
|
36470
|
+
})
|
|
36471
|
+
.filter(Boolean);
|
|
36472
|
+
}
|
|
36473
|
+
};
|
|
36474
|
+
if (personId && (personRequests === null || personRequests === void 0 ? void 0 : personRequests[personId])) {
|
|
36475
|
+
modifyRequests(personId);
|
|
36476
|
+
}
|
|
36477
|
+
else if (personRequests) {
|
|
36478
|
+
try {
|
|
36479
|
+
for (var _c = __values(Object.keys(personRequests)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
36480
|
+
var personId_2 = _d.value;
|
|
36481
|
+
modifyRequests(personId_2);
|
|
36482
|
+
}
|
|
36483
|
+
}
|
|
36484
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
36485
|
+
finally {
|
|
36486
|
+
try {
|
|
36487
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
36488
|
+
}
|
|
36489
|
+
finally { if (e_8) throw e_8.error; }
|
|
36490
|
+
}
|
|
36491
|
+
}
|
|
36492
|
+
var newRequests = requests.filter(function (request) { return !request.requestId; });
|
|
36493
|
+
if (newRequests.length) {
|
|
36494
|
+
mergePersonRequests({ personRequests: personRequests, personId: personId, requests: newRequests });
|
|
36495
|
+
}
|
|
36496
|
+
return savePersonRequests({ tournamentRecords: tournamentRecords, personRequests: personRequests });
|
|
36497
|
+
}
|
|
36498
|
+
|
|
36190
36499
|
function getEarliestCourtTime(_a) {
|
|
36191
36500
|
var averageMinutes = _a.averageMinutes, startTime = _a.startTime, endTime = _a.endTime, court = _a.court, date = _a.date;
|
|
36192
36501
|
if (!Array.isArray(court.dateAvailability))
|
|
@@ -36226,11 +36535,11 @@ function getEarliestCourtTime(_a) {
|
|
|
36226
36535
|
return { earliestCourtTime: earliestCourtTime, courtStartTime: courtStartTime, courtEndTime: courtEndTime };
|
|
36227
36536
|
}
|
|
36228
36537
|
|
|
36229
|
-
function
|
|
36538
|
+
function v2Scheduler(_a) {
|
|
36230
36539
|
var e_1, _b;
|
|
36231
36540
|
var _c, _d;
|
|
36232
36541
|
var schedulingProfileModifications = _a.schedulingProfileModifications, checkPotentialRequestConflicts = _a.checkPotentialRequestConflicts, scheduleCompletedMatchUps = _a.scheduleCompletedMatchUps, // override which can be used by mocksEngine
|
|
36233
|
-
schedulingProfileIssues = _a.schedulingProfileIssues, dateSchedulingProfiles = _a.dateSchedulingProfiles, containedStructureIds = _a.containedStructureIds, matchUpDependencies = _a.matchUpDependencies, matchUpDailyLimits = _a.matchUpDailyLimits, clearScheduleDates = _a.clearScheduleDates, tournamentRecords = _a.tournamentRecords, _e = _a.periodLength, periodLength = _e === void 0 ? 30 : _e, schedulingProfile = _a.schedulingProfile, personRequests = _a.personRequests,
|
|
36542
|
+
schedulingProfileIssues = _a.schedulingProfileIssues, dateSchedulingProfiles = _a.dateSchedulingProfiles, containedStructureIds = _a.containedStructureIds, matchUpDependencies = _a.matchUpDependencies, matchUpDailyLimits = _a.matchUpDailyLimits, clearScheduleDates = _a.clearScheduleDates, tournamentRecords = _a.tournamentRecords, _e = _a.periodLength, periodLength = _e === void 0 ? 30 : _e, schedulingProfile = _a.schedulingProfile, personRequests = _a.personRequests, _f = _a.matchUps, matchUps = _f === void 0 ? [] : _f, courts = _a.courts, dryRun = _a.dryRun;
|
|
36234
36543
|
var recoveryTimeDeferredMatchUpIds = {};
|
|
36235
36544
|
var dependencyDeferredMatchUpIds = {};
|
|
36236
36545
|
var scheduleDateRequestConflicts = {};
|
|
@@ -36241,7 +36550,7 @@ function proScheduler(_a) {
|
|
|
36241
36550
|
var noTimeMatchUpIds = {};
|
|
36242
36551
|
var requestConflicts = {};
|
|
36243
36552
|
var _loop_1 = function (dateSchedulingProfile) {
|
|
36244
|
-
var e_2,
|
|
36553
|
+
var e_2, _j, e_3, _k, e_4, _l, e_5, _m;
|
|
36245
36554
|
var scheduleDate = extractDate(dateSchedulingProfile === null || dateSchedulingProfile === void 0 ? void 0 : dateSchedulingProfile.scheduleDate);
|
|
36246
36555
|
var venues = (dateSchedulingProfile === null || dateSchedulingProfile === void 0 ? void 0 : dateSchedulingProfile.venues) || [];
|
|
36247
36556
|
var matchUpPotentialParticipantIds = {};
|
|
@@ -36267,7 +36576,7 @@ function proScheduler(_a) {
|
|
|
36267
36576
|
requestConflicts[scheduleDate] = [];
|
|
36268
36577
|
// Build up matchUpNotBeforeTimes for all matchUps already scheduled on scheduleDate
|
|
36269
36578
|
var matchUpNotBeforeTimes = {};
|
|
36270
|
-
matchUps.forEach(function (matchUp) {
|
|
36579
|
+
matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(function (matchUp) {
|
|
36271
36580
|
var _a;
|
|
36272
36581
|
if (((_a = matchUp.schedule) === null || _a === void 0 ? void 0 : _a.scheduledDate) &&
|
|
36273
36582
|
sameDay(scheduleDate, extractDate(matchUp.schedule.scheduledDate))) {
|
|
@@ -36278,7 +36587,7 @@ function proScheduler(_a) {
|
|
|
36278
36587
|
});
|
|
36279
36588
|
}
|
|
36280
36589
|
});
|
|
36281
|
-
var
|
|
36590
|
+
var _o = getVenueSchedulingDetails({
|
|
36282
36591
|
matchUpPotentialParticipantIds: matchUpPotentialParticipantIds,
|
|
36283
36592
|
individualParticipantProfiles: individualParticipantProfiles,
|
|
36284
36593
|
scheduleCompletedMatchUps: scheduleCompletedMatchUps,
|
|
@@ -36293,8 +36602,8 @@ function proScheduler(_a) {
|
|
|
36293
36602
|
matchUps: matchUps,
|
|
36294
36603
|
courts: courts,
|
|
36295
36604
|
venues: venues,
|
|
36296
|
-
}),
|
|
36297
|
-
var dateScheduledMatchUps = matchUps.filter(function (_a) {
|
|
36605
|
+
}), allDateScheduledByeMatchUpDetails = _o.allDateScheduledByeMatchUpDetails, allDateScheduledMatchUpIds = _o.allDateScheduledMatchUpIds, venueScheduledRoundDetails = _o.venueScheduledRoundDetails, allDateMatchUpIds = _o.allDateMatchUpIds;
|
|
36606
|
+
var dateScheduledMatchUps = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(function (_a) {
|
|
36298
36607
|
var matchUpId = _a.matchUpId;
|
|
36299
36608
|
return allDateScheduledMatchUpIds.includes(matchUpId);
|
|
36300
36609
|
});
|
|
@@ -36337,7 +36646,7 @@ function proScheduler(_a) {
|
|
|
36337
36646
|
var schedulingComplete = void 0;
|
|
36338
36647
|
while (!schedulingComplete) {
|
|
36339
36648
|
var _loop_2 = function (venueId) {
|
|
36340
|
-
var e_6,
|
|
36649
|
+
var e_6, _t;
|
|
36341
36650
|
var details = venueScheduledRoundDetails[venueId];
|
|
36342
36651
|
// on each pass attempt to schedule one matchUp per court
|
|
36343
36652
|
// when a matchUp is scheduled, add it to details.dateScheduledMatchUps
|
|
@@ -36348,30 +36657,30 @@ function proScheduler(_a) {
|
|
|
36348
36657
|
var passIterations = 0;
|
|
36349
36658
|
while (!venuePassComplete) {
|
|
36350
36659
|
var _loop_4 = function (matchUp) {
|
|
36351
|
-
var
|
|
36660
|
+
var _w;
|
|
36352
36661
|
if (courtIdsScheduled.length === details.courtsCount ||
|
|
36353
36662
|
matchUpIdsScheduled.length === details.courtsCount) {
|
|
36354
36663
|
venuePassComplete = true;
|
|
36355
36664
|
return "break";
|
|
36356
36665
|
}
|
|
36357
36666
|
var matchUpId = matchUp.matchUpId, matchUpType = matchUp.matchUpType;
|
|
36358
|
-
var
|
|
36667
|
+
var _x = checkDailyLimits({
|
|
36359
36668
|
matchUpPotentialParticipantIds: matchUpPotentialParticipantIds,
|
|
36360
36669
|
individualParticipantProfiles: individualParticipantProfiles,
|
|
36361
36670
|
matchUpDailyLimits: matchUpDailyLimits,
|
|
36362
36671
|
matchUp: matchUp,
|
|
36363
|
-
}), participantIdsAtLimit =
|
|
36672
|
+
}), participantIdsAtLimit = _x.participantIdsAtLimit, relevantParticipantIds = _x.relevantParticipantIds;
|
|
36364
36673
|
if (participantIdsAtLimit.length) {
|
|
36365
36674
|
if (!overLimitMatchUpIds[scheduleDate].includes(matchUpId))
|
|
36366
36675
|
overLimitMatchUpIds[scheduleDate].push(matchUpId);
|
|
36367
36676
|
return "continue";
|
|
36368
36677
|
}
|
|
36369
|
-
var
|
|
36678
|
+
var _y = checkDependenciesScheduled({
|
|
36370
36679
|
matchUpScheduleTimes: matchUpScheduleTimes,
|
|
36371
36680
|
matchUpDependencies: matchUpDependencies,
|
|
36372
36681
|
allDateMatchUpIds: allDateMatchUpIds,
|
|
36373
36682
|
matchUp: matchUp,
|
|
36374
|
-
}), dependenciesScheduled =
|
|
36683
|
+
}), dependenciesScheduled = _y.dependenciesScheduled, remainingDependencies = _y.remainingDependencies;
|
|
36375
36684
|
if (!dependenciesScheduled) {
|
|
36376
36685
|
if (!dependencyDeferredMatchUpIds[scheduleDate][matchUpId])
|
|
36377
36686
|
dependencyDeferredMatchUpIds[scheduleDate][matchUpId] = [];
|
|
@@ -36483,12 +36792,12 @@ function proScheduler(_a) {
|
|
|
36483
36792
|
else if (schedulingConflicts === null || schedulingConflicts === void 0 ? void 0 : schedulingConflicts.length) {
|
|
36484
36793
|
if (!scheduleDateRequestConflicts[scheduleDate])
|
|
36485
36794
|
scheduleDateRequestConflicts[scheduleDate] = [];
|
|
36486
|
-
(
|
|
36795
|
+
(_w = scheduleDateRequestConflicts[scheduleDate]).push.apply(_w, __spreadArray([], __read(schedulingConflicts), false));
|
|
36487
36796
|
}
|
|
36488
36797
|
};
|
|
36489
36798
|
try {
|
|
36490
|
-
for (var
|
|
36491
|
-
var matchUp =
|
|
36799
|
+
for (var _u = (e_6 = void 0, __values(details.matchUpsToSchedule)), _v = _u.next(); !_v.done; _v = _u.next()) {
|
|
36800
|
+
var matchUp = _v.value;
|
|
36492
36801
|
var state_1 = _loop_4(matchUp);
|
|
36493
36802
|
if (state_1 === "break")
|
|
36494
36803
|
break;
|
|
@@ -36497,7 +36806,7 @@ function proScheduler(_a) {
|
|
|
36497
36806
|
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
36498
36807
|
finally {
|
|
36499
36808
|
try {
|
|
36500
|
-
if (
|
|
36809
|
+
if (_v && !_v.done && (_t = _u.return)) _t.call(_u);
|
|
36501
36810
|
}
|
|
36502
36811
|
finally { if (e_6) throw e_6.error; }
|
|
36503
36812
|
}
|
|
@@ -36536,7 +36845,7 @@ function proScheduler(_a) {
|
|
|
36536
36845
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
36537
36846
|
finally {
|
|
36538
36847
|
try {
|
|
36539
|
-
if (venues_1_1 && !venues_1_1.done && (
|
|
36848
|
+
if (venues_1_1 && !venues_1_1.done && (_j = venues_1.return)) _j.call(venues_1);
|
|
36540
36849
|
}
|
|
36541
36850
|
finally { if (e_2) throw e_2.error; }
|
|
36542
36851
|
}
|
|
@@ -36610,17 +36919,32 @@ function proScheduler(_a) {
|
|
|
36610
36919
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
36611
36920
|
finally {
|
|
36612
36921
|
try {
|
|
36613
|
-
if (venues_2_1 && !venues_2_1.done && (
|
|
36922
|
+
if (venues_2_1 && !venues_2_1.done && (_k = venues_2.return)) _k.call(venues_2);
|
|
36614
36923
|
}
|
|
36615
36924
|
finally { if (e_3) throw e_3.error; }
|
|
36616
36925
|
}
|
|
36617
|
-
if (!dryRun && (
|
|
36926
|
+
if (!dryRun && (allDateScheduledByeMatchUpDetails === null || allDateScheduledByeMatchUpDetails === void 0 ? void 0 : allDateScheduledByeMatchUpDetails.length)) {
|
|
36927
|
+
// remove scheduling information for BYE matchUps from any rounds that were scheduled
|
|
36928
|
+
bulkScheduleMatchUps({
|
|
36929
|
+
matchUpDetails: allDateScheduledByeMatchUpDetails,
|
|
36930
|
+
scheduleByeMatchUps: true,
|
|
36931
|
+
removePriorValues: true,
|
|
36932
|
+
tournamentRecords: tournamentRecords,
|
|
36933
|
+
schedule: {
|
|
36934
|
+
scheduledDate: '',
|
|
36935
|
+
scheduledTime: '',
|
|
36936
|
+
courtOrder: '',
|
|
36937
|
+
courtId: '',
|
|
36938
|
+
venueId: '',
|
|
36939
|
+
},
|
|
36940
|
+
});
|
|
36941
|
+
}
|
|
36618
36942
|
try {
|
|
36619
|
-
for (var
|
|
36620
|
-
var venue =
|
|
36943
|
+
for (var _p = (e_4 = void 0, __values(dateSchedulingProfile.venues)), _q = _p.next(); !_q.done; _q = _p.next()) {
|
|
36944
|
+
var venue = _q.value;
|
|
36621
36945
|
try {
|
|
36622
|
-
for (var
|
|
36623
|
-
var round =
|
|
36946
|
+
for (var _r = (e_5 = void 0, __values(venue.rounds)), _s = _r.next(); !_s.done; _s = _r.next()) {
|
|
36947
|
+
var round = _s.value;
|
|
36624
36948
|
var matchUpIds = ((_d = round.matchUps) !== null && _d !== void 0 ? _d : []).map(function (_a) {
|
|
36625
36949
|
var matchUpId = _a.matchUpId;
|
|
36626
36950
|
return matchUpId;
|
|
@@ -36641,7 +36965,7 @@ function proScheduler(_a) {
|
|
|
36641
36965
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
36642
36966
|
finally {
|
|
36643
36967
|
try {
|
|
36644
|
-
if (
|
|
36968
|
+
if (_s && !_s.done && (_m = _r.return)) _m.call(_r);
|
|
36645
36969
|
}
|
|
36646
36970
|
finally { if (e_5) throw e_5.error; }
|
|
36647
36971
|
}
|
|
@@ -36650,27 +36974,27 @@ function proScheduler(_a) {
|
|
|
36650
36974
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
36651
36975
|
finally {
|
|
36652
36976
|
try {
|
|
36653
|
-
if (
|
|
36977
|
+
if (_q && !_q.done && (_l = _p.return)) _l.call(_p);
|
|
36654
36978
|
}
|
|
36655
36979
|
finally { if (e_4) throw e_4.error; }
|
|
36656
36980
|
}
|
|
36657
36981
|
};
|
|
36658
36982
|
try {
|
|
36659
36983
|
// Start SCHEDULING
|
|
36660
|
-
for (var
|
|
36661
|
-
var dateSchedulingProfile =
|
|
36984
|
+
for (var _g = __values(dateSchedulingProfiles !== null && dateSchedulingProfiles !== void 0 ? dateSchedulingProfiles : []), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
36985
|
+
var dateSchedulingProfile = _h.value;
|
|
36662
36986
|
_loop_1(dateSchedulingProfile);
|
|
36663
36987
|
}
|
|
36664
36988
|
}
|
|
36665
36989
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36666
36990
|
finally {
|
|
36667
36991
|
try {
|
|
36668
|
-
if (
|
|
36992
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
36669
36993
|
}
|
|
36670
36994
|
finally { if (e_1) throw e_1.error; }
|
|
36671
36995
|
}
|
|
36672
36996
|
// returns the original form of the dateStrings, before extractDate()
|
|
36673
|
-
var scheduledDates = dateSchedulingProfiles.map(function (_a) {
|
|
36997
|
+
var scheduledDates = (dateSchedulingProfiles !== null && dateSchedulingProfiles !== void 0 ? dateSchedulingProfiles : []).map(function (_a) {
|
|
36674
36998
|
var scheduleDate = _a.scheduleDate;
|
|
36675
36999
|
return scheduleDate;
|
|
36676
37000
|
});
|
|
@@ -36687,285 +37011,6 @@ function proScheduler(_a) {
|
|
|
36687
37011
|
return __assign(__assign({}, SUCCESS), { schedulingProfileModifications: schedulingProfileModifications, schedulingProfileIssues: schedulingProfileIssues, dateSchedulingProfiles: dateSchedulingProfiles, recoveryTimeDeferredMatchUpIds: recoveryTimeDeferredMatchUpIds, dependencyDeferredMatchUpIds: dependencyDeferredMatchUpIds, matchUpScheduleTimes: matchUpScheduleTimes, overLimitMatchUpIds: overLimitMatchUpIds, scheduledMatchUpIds: scheduledMatchUpIds, noTimeMatchUpIds: noTimeMatchUpIds, requestConflicts: requestConflicts, scheduledDates: scheduledDates });
|
|
36688
37012
|
}
|
|
36689
37013
|
|
|
36690
|
-
function getPersonRequests(_a) {
|
|
36691
|
-
var e_1, _b, e_2, _c, e_3, _d;
|
|
36692
|
-
var tournamentRecords = _a.tournamentRecords, requestType = _a.requestType;
|
|
36693
|
-
if (typeof tournamentRecords !== 'object' ||
|
|
36694
|
-
!Object.keys(tournamentRecords).length)
|
|
36695
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36696
|
-
var personRequests = {};
|
|
36697
|
-
try {
|
|
36698
|
-
// create merged view of person requests across tournamentRecords
|
|
36699
|
-
// ... possible for a person to be in multiple linked tournamentRecords
|
|
36700
|
-
for (var _e = __values(Object.values(tournamentRecords)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
36701
|
-
var tournamentRecord = _f.value;
|
|
36702
|
-
var extension = findTournamentExtension({
|
|
36703
|
-
name: PERSON_REQUESTS,
|
|
36704
|
-
tournamentRecord: tournamentRecord,
|
|
36705
|
-
}).extension;
|
|
36706
|
-
var requestObjects = (extension === null || extension === void 0 ? void 0 : extension.value) || [];
|
|
36707
|
-
try {
|
|
36708
|
-
for (var requestObjects_1 = (e_2 = void 0, __values(requestObjects)), requestObjects_1_1 = requestObjects_1.next(); !requestObjects_1_1.done; requestObjects_1_1 = requestObjects_1.next()) {
|
|
36709
|
-
var requestObject = requestObjects_1_1.value;
|
|
36710
|
-
var _g = requestObject || {}, personId = _g.personId, requests = _g.requests;
|
|
36711
|
-
if (!personRequests[personId])
|
|
36712
|
-
personRequests[personId] = [];
|
|
36713
|
-
try {
|
|
36714
|
-
for (var requests_1 = (e_3 = void 0, __values(requests)), requests_1_1 = requests_1.next(); !requests_1_1.done; requests_1_1 = requests_1.next()) {
|
|
36715
|
-
var request = requests_1_1.value;
|
|
36716
|
-
if (requestType && request.requestType !== requestType)
|
|
36717
|
-
continue;
|
|
36718
|
-
personRequests[personId].push(request);
|
|
36719
|
-
}
|
|
36720
|
-
}
|
|
36721
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
36722
|
-
finally {
|
|
36723
|
-
try {
|
|
36724
|
-
if (requests_1_1 && !requests_1_1.done && (_d = requests_1.return)) _d.call(requests_1);
|
|
36725
|
-
}
|
|
36726
|
-
finally { if (e_3) throw e_3.error; }
|
|
36727
|
-
}
|
|
36728
|
-
}
|
|
36729
|
-
}
|
|
36730
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
36731
|
-
finally {
|
|
36732
|
-
try {
|
|
36733
|
-
if (requestObjects_1_1 && !requestObjects_1_1.done && (_c = requestObjects_1.return)) _c.call(requestObjects_1);
|
|
36734
|
-
}
|
|
36735
|
-
finally { if (e_2) throw e_2.error; }
|
|
36736
|
-
}
|
|
36737
|
-
}
|
|
36738
|
-
}
|
|
36739
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36740
|
-
finally {
|
|
36741
|
-
try {
|
|
36742
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
36743
|
-
}
|
|
36744
|
-
finally { if (e_1) throw e_1.error; }
|
|
36745
|
-
}
|
|
36746
|
-
// audit requests and filter out any that are no longer relevant
|
|
36747
|
-
// (tournament dates changed & etc)
|
|
36748
|
-
return { personRequests: personRequests };
|
|
36749
|
-
}
|
|
36750
|
-
function savePersonRequests(_a) {
|
|
36751
|
-
var e_4, _b, e_5, _c;
|
|
36752
|
-
var _d;
|
|
36753
|
-
var tournamentRecords = _a.tournamentRecords, personRequests = _a.personRequests;
|
|
36754
|
-
if (!tournamentRecords)
|
|
36755
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36756
|
-
if (!personRequests)
|
|
36757
|
-
return __assign({}, SUCCESS);
|
|
36758
|
-
var tournaments = Object.values(tournamentRecords);
|
|
36759
|
-
try {
|
|
36760
|
-
for (var tournaments_1 = __values(tournaments), tournaments_1_1 = tournaments_1.next(); !tournaments_1_1.done; tournaments_1_1 = tournaments_1.next()) {
|
|
36761
|
-
var tournamentRecord = tournaments_1_1.value;
|
|
36762
|
-
var tournamentParticipants = (_d = tournamentRecord.participants) !== null && _d !== void 0 ? _d : [];
|
|
36763
|
-
var relevantPersonRequests = [];
|
|
36764
|
-
try {
|
|
36765
|
-
for (var _e = (e_5 = void 0, __values(Object.keys(personRequests))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
36766
|
-
var personId = _f.value;
|
|
36767
|
-
if (findParticipant({ tournamentParticipants: tournamentParticipants, personId: personId })) {
|
|
36768
|
-
var requests = personRequests[personId];
|
|
36769
|
-
if (requests.length)
|
|
36770
|
-
relevantPersonRequests.push({ personId: personId, requests: requests });
|
|
36771
|
-
}
|
|
36772
|
-
}
|
|
36773
|
-
}
|
|
36774
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
36775
|
-
finally {
|
|
36776
|
-
try {
|
|
36777
|
-
if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
|
|
36778
|
-
}
|
|
36779
|
-
finally { if (e_5) throw e_5.error; }
|
|
36780
|
-
}
|
|
36781
|
-
if (Object.keys(relevantPersonRequests).length) {
|
|
36782
|
-
var extension = {
|
|
36783
|
-
name: PERSON_REQUESTS,
|
|
36784
|
-
value: relevantPersonRequests,
|
|
36785
|
-
};
|
|
36786
|
-
addTournamentExtension({ tournamentRecord: tournamentRecord, extension: extension });
|
|
36787
|
-
}
|
|
36788
|
-
}
|
|
36789
|
-
}
|
|
36790
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
36791
|
-
finally {
|
|
36792
|
-
try {
|
|
36793
|
-
if (tournaments_1_1 && !tournaments_1_1.done && (_b = tournaments_1.return)) _b.call(tournaments_1);
|
|
36794
|
-
}
|
|
36795
|
-
finally { if (e_4) throw e_4.error; }
|
|
36796
|
-
}
|
|
36797
|
-
return __assign({}, SUCCESS);
|
|
36798
|
-
}
|
|
36799
|
-
function addPersonRequests(_a) {
|
|
36800
|
-
var tournamentRecords = _a.tournamentRecords, personId = _a.personId, requests = _a.requests;
|
|
36801
|
-
if (!tournamentRecords)
|
|
36802
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36803
|
-
if (typeof personId !== 'string')
|
|
36804
|
-
return { error: INVALID_VALUES };
|
|
36805
|
-
if (!Array.isArray(requests))
|
|
36806
|
-
return { error: INVALID_VALUES };
|
|
36807
|
-
var personRequests = getPersonRequests({ tournamentRecords: tournamentRecords }).personRequests;
|
|
36808
|
-
var mergeCount = mergePersonRequests({
|
|
36809
|
-
personRequests: personRequests,
|
|
36810
|
-
personId: personId,
|
|
36811
|
-
requests: requests,
|
|
36812
|
-
}).mergeCount;
|
|
36813
|
-
if (mergeCount && personRequests) {
|
|
36814
|
-
return savePersonRequests({ tournamentRecords: tournamentRecords, personRequests: personRequests });
|
|
36815
|
-
}
|
|
36816
|
-
else {
|
|
36817
|
-
return { error: INVALID_VALUES };
|
|
36818
|
-
}
|
|
36819
|
-
}
|
|
36820
|
-
// check whether there is a request for the date with overlapping times
|
|
36821
|
-
// extend startTime/endTime rather than creating multiple
|
|
36822
|
-
// ... only pertains to { requestType: DO_NOT_SCHEDULE }
|
|
36823
|
-
function mergePersonRequests(_a) {
|
|
36824
|
-
var e_6, _b;
|
|
36825
|
-
var personRequests = _a.personRequests, personId = _a.personId, requests = _a.requests;
|
|
36826
|
-
if (!personRequests[personId])
|
|
36827
|
-
personRequests[personId] = [];
|
|
36828
|
-
var filteredRequests = requests
|
|
36829
|
-
.filter(function (_a) {
|
|
36830
|
-
var requestType = _a.requestType;
|
|
36831
|
-
return requestType;
|
|
36832
|
-
})
|
|
36833
|
-
.map(function (request) {
|
|
36834
|
-
var date = request.date, startTime = request.startTime, endTime = request.endTime;
|
|
36835
|
-
// validate requestType
|
|
36836
|
-
if (request.requestType === DO_NOT_SCHEDULE) {
|
|
36837
|
-
date = extractDate(date);
|
|
36838
|
-
startTime = extractTime(startTime);
|
|
36839
|
-
endTime = extractTime(endTime);
|
|
36840
|
-
if (date && startTime && endTime) {
|
|
36841
|
-
return { date: date, startTime: startTime, endTime: endTime, requestType: request.requestType };
|
|
36842
|
-
}
|
|
36843
|
-
}
|
|
36844
|
-
return request;
|
|
36845
|
-
})
|
|
36846
|
-
.filter(Boolean);
|
|
36847
|
-
try {
|
|
36848
|
-
// Do not add any request that is missing requestType
|
|
36849
|
-
for (var filteredRequests_1 = __values(filteredRequests), filteredRequests_1_1 = filteredRequests_1.next(); !filteredRequests_1_1.done; filteredRequests_1_1 = filteredRequests_1.next()) {
|
|
36850
|
-
var request = filteredRequests_1_1.value;
|
|
36851
|
-
request.requestId = generateTimeCode();
|
|
36852
|
-
personRequests[personId].push(request);
|
|
36853
|
-
}
|
|
36854
|
-
}
|
|
36855
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
36856
|
-
finally {
|
|
36857
|
-
try {
|
|
36858
|
-
if (filteredRequests_1_1 && !filteredRequests_1_1.done && (_b = filteredRequests_1.return)) _b.call(filteredRequests_1);
|
|
36859
|
-
}
|
|
36860
|
-
finally { if (e_6) throw e_6.error; }
|
|
36861
|
-
}
|
|
36862
|
-
return { mergeCount: filteredRequests.length };
|
|
36863
|
-
}
|
|
36864
|
-
// personRequests can be removed by date, requestId, or requestType
|
|
36865
|
-
function removePersonRequests(_a) {
|
|
36866
|
-
var e_7, _b;
|
|
36867
|
-
var tournamentRecords = _a.tournamentRecords, requestType = _a.requestType, requestId = _a.requestId, personId = _a.personId, date = _a.date;
|
|
36868
|
-
if (typeof tournamentRecords !== 'object' ||
|
|
36869
|
-
!Object.keys(tournamentRecords).length)
|
|
36870
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36871
|
-
var personRequests = getPersonRequests({ tournamentRecords: tournamentRecords }).personRequests;
|
|
36872
|
-
var filterRequests = function (personId) {
|
|
36873
|
-
var _a;
|
|
36874
|
-
if (personRequests) {
|
|
36875
|
-
personRequests[personId] = personRequests[personId].filter(function (request) {
|
|
36876
|
-
return ((!requestType || request.requestType !== requestType) &&
|
|
36877
|
-
(!requestId || request.requestId !== requestId) &&
|
|
36878
|
-
(!date || request.date !== date));
|
|
36879
|
-
});
|
|
36880
|
-
if (!((_a = personRequests === null || personRequests === void 0 ? void 0 : personRequests[personId]) === null || _a === void 0 ? void 0 : _a.length))
|
|
36881
|
-
delete personRequests[personId];
|
|
36882
|
-
}
|
|
36883
|
-
};
|
|
36884
|
-
var removeAll = !requestType && !requestId && !personId && !date;
|
|
36885
|
-
if (!removeAll) {
|
|
36886
|
-
if (personId && (personRequests === null || personRequests === void 0 ? void 0 : personRequests[personId])) {
|
|
36887
|
-
filterRequests(personId);
|
|
36888
|
-
}
|
|
36889
|
-
else if (personRequests) {
|
|
36890
|
-
try {
|
|
36891
|
-
for (var _c = __values(Object.keys(personRequests)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
36892
|
-
var personId_1 = _d.value;
|
|
36893
|
-
filterRequests(personId_1);
|
|
36894
|
-
}
|
|
36895
|
-
}
|
|
36896
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
36897
|
-
finally {
|
|
36898
|
-
try {
|
|
36899
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
36900
|
-
}
|
|
36901
|
-
finally { if (e_7) throw e_7.error; }
|
|
36902
|
-
}
|
|
36903
|
-
}
|
|
36904
|
-
}
|
|
36905
|
-
if (removeAll || !personRequests || !Object.keys(personRequests).length) {
|
|
36906
|
-
return removeExtension({ tournamentRecords: tournamentRecords, name: PERSON_REQUESTS });
|
|
36907
|
-
}
|
|
36908
|
-
else {
|
|
36909
|
-
return savePersonRequests({ tournamentRecords: tournamentRecords, personRequests: personRequests });
|
|
36910
|
-
}
|
|
36911
|
-
}
|
|
36912
|
-
// can be used to both add and remove requests
|
|
36913
|
-
// requests which don't have existing requestId will be added
|
|
36914
|
-
// requests which don't have requestType will be removed
|
|
36915
|
-
function modifyPersonRequests(_a) {
|
|
36916
|
-
var e_8, _b;
|
|
36917
|
-
var tournamentRecords = _a.tournamentRecords, requests = _a.requests, personId = _a.personId;
|
|
36918
|
-
if (!tournamentRecords)
|
|
36919
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
36920
|
-
if (!Array.isArray(requests))
|
|
36921
|
-
return { error: INVALID_VALUES };
|
|
36922
|
-
var requestIds = requests.map(function (_a) {
|
|
36923
|
-
var requestId = _a.requestId;
|
|
36924
|
-
return requestId;
|
|
36925
|
-
}).filter(Boolean);
|
|
36926
|
-
var personRequests = getPersonRequests({ tournamentRecords: tournamentRecords }).personRequests;
|
|
36927
|
-
var modifyRequests = function (personId) {
|
|
36928
|
-
if (personRequests) {
|
|
36929
|
-
personRequests[personId] = personRequests[personId]
|
|
36930
|
-
.map(function (request) {
|
|
36931
|
-
// if requestId not in requestIds then return unmodified
|
|
36932
|
-
if (!requestIds.includes(request.requestId))
|
|
36933
|
-
return request;
|
|
36934
|
-
// find the updatedRequest
|
|
36935
|
-
var modification = requests.find(function (updatedRequest) { return updatedRequest.requestId === request.requestId; });
|
|
36936
|
-
// FEATURE: returning an updatedRequest without a requestType will remove it
|
|
36937
|
-
if (!modification.requestType)
|
|
36938
|
-
return;
|
|
36939
|
-
return Object.assign(request, modification);
|
|
36940
|
-
})
|
|
36941
|
-
.filter(Boolean);
|
|
36942
|
-
}
|
|
36943
|
-
};
|
|
36944
|
-
if (personId && (personRequests === null || personRequests === void 0 ? void 0 : personRequests[personId])) {
|
|
36945
|
-
modifyRequests(personId);
|
|
36946
|
-
}
|
|
36947
|
-
else if (personRequests) {
|
|
36948
|
-
try {
|
|
36949
|
-
for (var _c = __values(Object.keys(personRequests)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
36950
|
-
var personId_2 = _d.value;
|
|
36951
|
-
modifyRequests(personId_2);
|
|
36952
|
-
}
|
|
36953
|
-
}
|
|
36954
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
36955
|
-
finally {
|
|
36956
|
-
try {
|
|
36957
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
36958
|
-
}
|
|
36959
|
-
finally { if (e_8) throw e_8.error; }
|
|
36960
|
-
}
|
|
36961
|
-
}
|
|
36962
|
-
var newRequests = requests.filter(function (request) { return !request.requestId; });
|
|
36963
|
-
if (newRequests.length) {
|
|
36964
|
-
mergePersonRequests({ personRequests: personRequests, personId: personId, requests: newRequests });
|
|
36965
|
-
}
|
|
36966
|
-
return savePersonRequests({ tournamentRecords: tournamentRecords, personRequests: personRequests });
|
|
36967
|
-
}
|
|
36968
|
-
|
|
36969
37014
|
function clearScheduledMatchUps$1(_a) {
|
|
36970
37015
|
var e_1, _b;
|
|
36971
37016
|
var _c, _d, _e;
|
|
@@ -37099,7 +37144,7 @@ function getMatchUpDailyLimits(_a) {
|
|
|
37099
37144
|
|
|
37100
37145
|
// abstraction layer to allow other schedulers to be defined at a later time
|
|
37101
37146
|
function scheduleProfileRounds(_a) {
|
|
37102
|
-
var _b = _a.checkPotentialRequestConflicts, checkPotentialRequestConflicts = _b === void 0 ? true : _b, scheduleCompletedMatchUps = _a.scheduleCompletedMatchUps, clearScheduleDates = _a.clearScheduleDates, _c = _a.scheduleDates, scheduleDates = _c === void 0 ? [] : _c, tournamentRecords = _a.tournamentRecords, periodLength = _a.periodLength, dryRun = _a.dryRun, pro = _a.pro;
|
|
37147
|
+
var _b = _a.checkPotentialRequestConflicts, checkPotentialRequestConflicts = _b === void 0 ? true : _b, scheduleCompletedMatchUps = _a.scheduleCompletedMatchUps, clearScheduleDates = _a.clearScheduleDates, _c = _a.scheduleDates, scheduleDates = _c === void 0 ? [] : _c, tournamentRecords = _a.tournamentRecords, periodLength = _a.periodLength, useGarman = _a.useGarman, dryRun = _a.dryRun, pro = _a.pro;
|
|
37103
37148
|
if (!tournamentRecords)
|
|
37104
37149
|
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
37105
37150
|
if (!Array.isArray(scheduleDates))
|
|
@@ -37107,7 +37152,7 @@ function scheduleProfileRounds(_a) {
|
|
|
37107
37152
|
var result = getSchedulingProfile$1({ tournamentRecords: tournamentRecords });
|
|
37108
37153
|
if (result.error)
|
|
37109
37154
|
return result;
|
|
37110
|
-
var _d = result.
|
|
37155
|
+
var schedulingProfileModifications = result.modifications, _d = result.issues, schedulingProfileIssues = _d === void 0 ? [] : _d, _e = result.schedulingProfile, schedulingProfile = _e === void 0 ? [] : _e;
|
|
37111
37156
|
// round robin structures contain other structures and the scheduler
|
|
37112
37157
|
// needs to reference the containing structure by contained structureIds
|
|
37113
37158
|
var containedStructureIds = Object.assign.apply(Object, __spreadArray([{}], __read(Object.values(tournamentRecords).map(function (tournamentRecord) {
|
|
@@ -37186,12 +37231,13 @@ function scheduleProfileRounds(_a) {
|
|
|
37186
37231
|
schedulingProfile: schedulingProfile,
|
|
37187
37232
|
personRequests: personRequests,
|
|
37188
37233
|
periodLength: periodLength,
|
|
37234
|
+
useGarman: useGarman,
|
|
37189
37235
|
matchUps: matchUps,
|
|
37190
37236
|
dryRun: dryRun,
|
|
37191
37237
|
courts: courts,
|
|
37192
37238
|
};
|
|
37193
37239
|
if (pro) {
|
|
37194
|
-
return
|
|
37240
|
+
return v2Scheduler(params);
|
|
37195
37241
|
}
|
|
37196
37242
|
else {
|
|
37197
37243
|
return jinnScheduler(params);
|
|
@@ -40551,7 +40597,7 @@ function deletionMessage(_a) {
|
|
|
40551
40597
|
|
|
40552
40598
|
function deleteVenue$1(_a) {
|
|
40553
40599
|
var e_1, _b;
|
|
40554
|
-
var _c, _d;
|
|
40600
|
+
var _c, _d, _e, _f, _g;
|
|
40555
40601
|
var tournamentRecord = _a.tournamentRecord, venueId = _a.venueId, force = _a.force;
|
|
40556
40602
|
if (!tournamentRecord)
|
|
40557
40603
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
@@ -40562,7 +40608,11 @@ function deleteVenue$1(_a) {
|
|
|
40562
40608
|
tournamentRecord: tournamentRecord,
|
|
40563
40609
|
contextFilters: contextFilters,
|
|
40564
40610
|
}).matchUps) !== null && _c !== void 0 ? _c : [];
|
|
40565
|
-
|
|
40611
|
+
var appliedPolicies = (_d = getAppliedPolicies({
|
|
40612
|
+
tournamentRecord: tournamentRecord,
|
|
40613
|
+
})) === null || _d === void 0 ? void 0 : _d.appliedPolicies;
|
|
40614
|
+
var allowModificationWhenMatchUpsScheduled = force !== null && force !== void 0 ? force : (_f = (_e = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCHEDULING]) === null || _e === void 0 ? void 0 : _e.allowDeletionWithScoresPresent) === null || _f === void 0 ? void 0 : _f.venues;
|
|
40615
|
+
if (!matchUpsToUnschedule.length || allowModificationWhenMatchUpsScheduled) {
|
|
40566
40616
|
try {
|
|
40567
40617
|
// if no matchUpsToUnschedule this does nothing but avoid the deletionMessage
|
|
40568
40618
|
for (var matchUpsToUnschedule_1 = __values(matchUpsToUnschedule), matchUpsToUnschedule_1_1 = matchUpsToUnschedule_1.next(); !matchUpsToUnschedule_1_1.done; matchUpsToUnschedule_1_1 = matchUpsToUnschedule_1.next()) {
|
|
@@ -40588,7 +40638,7 @@ function deleteVenue$1(_a) {
|
|
|
40588
40638
|
return deletionMessage({ matchUpsCount: matchUpsToUnschedule.length });
|
|
40589
40639
|
}
|
|
40590
40640
|
var deleted;
|
|
40591
|
-
tournamentRecord.venues = ((
|
|
40641
|
+
tournamentRecord.venues = ((_g = tournamentRecord.venues) !== null && _g !== void 0 ? _g : []).filter(function (venue) {
|
|
40592
40642
|
if ((venue === null || venue === void 0 ? void 0 : venue.venueId) !== venueId)
|
|
40593
40643
|
return true;
|
|
40594
40644
|
deleted = true;
|
|
@@ -40808,8 +40858,8 @@ function getScheduledVenueMatchUps(_a) {
|
|
|
40808
40858
|
|
|
40809
40859
|
function deleteCourt$1(_a) {
|
|
40810
40860
|
var e_1, _b;
|
|
40811
|
-
var _c;
|
|
40812
|
-
var tournamentRecord = _a.tournamentRecord,
|
|
40861
|
+
var _c, _d, _e, _f;
|
|
40862
|
+
var tournamentRecord = _a.tournamentRecord, disableNotice = _a.disableNotice, courtId = _a.courtId, force = _a.force;
|
|
40813
40863
|
var result = findCourt({ tournamentRecord: tournamentRecord, courtId: courtId });
|
|
40814
40864
|
if (result.error)
|
|
40815
40865
|
return result;
|
|
@@ -40818,15 +40868,18 @@ function deleteCourt$1(_a) {
|
|
|
40818
40868
|
tournamentRecord: tournamentRecord,
|
|
40819
40869
|
courtId: courtId,
|
|
40820
40870
|
}).matchUps;
|
|
40821
|
-
|
|
40871
|
+
var appliedPolicies = (_c = getAppliedPolicies({
|
|
40872
|
+
tournamentRecord: tournamentRecord,
|
|
40873
|
+
})) === null || _c === void 0 ? void 0 : _c.appliedPolicies;
|
|
40874
|
+
var allowModificationWhenMatchUpsScheduled = force !== null && force !== void 0 ? force : (_e = (_d = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCHEDULING]) === null || _d === void 0 ? void 0 : _d.allowDeletionWithScoresPresent) === null || _e === void 0 ? void 0 : _e.courts;
|
|
40875
|
+
if (!(matchUps === null || matchUps === void 0 ? void 0 : matchUps.length) || allowModificationWhenMatchUpsScheduled) {
|
|
40822
40876
|
try {
|
|
40823
|
-
for (var
|
|
40824
|
-
var matchUp =
|
|
40877
|
+
for (var _g = __values(matchUps !== null && matchUps !== void 0 ? matchUps : []), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
40878
|
+
var matchUp = _h.value;
|
|
40825
40879
|
var result_1 = removeCourtAssignment({
|
|
40826
40880
|
matchUpId: matchUp.matchUpId,
|
|
40827
40881
|
drawId: matchUp.drawId,
|
|
40828
40882
|
tournamentRecord: tournamentRecord,
|
|
40829
|
-
drawDefinition: drawDefinition,
|
|
40830
40883
|
});
|
|
40831
40884
|
if (result_1.error)
|
|
40832
40885
|
return result_1;
|
|
@@ -40835,12 +40888,12 @@ function deleteCourt$1(_a) {
|
|
|
40835
40888
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
40836
40889
|
finally {
|
|
40837
40890
|
try {
|
|
40838
|
-
if (
|
|
40891
|
+
if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
|
|
40839
40892
|
}
|
|
40840
40893
|
finally { if (e_1) throw e_1.error; }
|
|
40841
40894
|
}
|
|
40842
40895
|
if (venue) {
|
|
40843
|
-
venue.courts = ((
|
|
40896
|
+
venue.courts = ((_f = venue.courts) !== null && _f !== void 0 ? _f : []).filter(function (courtRecord) {
|
|
40844
40897
|
return courtRecord.courtId !== courtId;
|
|
40845
40898
|
});
|
|
40846
40899
|
if (!disableNotice)
|
|
@@ -41032,7 +41085,8 @@ function validDateAvailability(_a) {
|
|
|
41032
41085
|
}
|
|
41033
41086
|
|
|
41034
41087
|
function modifyCourtAvailability(_a) {
|
|
41035
|
-
var
|
|
41088
|
+
var _b, _c, _d;
|
|
41089
|
+
var tournamentRecord = _a.tournamentRecord, dateAvailability = _a.dateAvailability, disableNotice = _a.disableNotice, venueMatchUps = _a.venueMatchUps, courtId = _a.courtId, force = _a.force;
|
|
41036
41090
|
if (!tournamentRecord)
|
|
41037
41091
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
41038
41092
|
if (!courtId)
|
|
@@ -41040,7 +41094,10 @@ function modifyCourtAvailability(_a) {
|
|
|
41040
41094
|
var dateResult = validDateAvailability({ dateAvailability: dateAvailability });
|
|
41041
41095
|
if (dateResult.error)
|
|
41042
41096
|
return dateResult;
|
|
41043
|
-
|
|
41097
|
+
// TODO: build up a map of affected dates and:
|
|
41098
|
+
// 1. whether aggregate time on given dates has increased or decreased
|
|
41099
|
+
// 2. specific periods of time on given dates that are no longer available
|
|
41100
|
+
var _e = sortAndMergeDateAvailability(dateAvailability), updatedDateAvailability = _e.updatedDateAvailability, totalMergeCount = _e.totalMergeCount;
|
|
41044
41101
|
dateAvailability = updatedDateAvailability;
|
|
41045
41102
|
var courtResult = findCourt({ tournamentRecord: tournamentRecord, courtId: courtId });
|
|
41046
41103
|
if (courtResult.error)
|
|
@@ -41052,10 +41109,24 @@ function modifyCourtAvailability(_a) {
|
|
|
41052
41109
|
courtId: courtId,
|
|
41053
41110
|
}).matchUps;
|
|
41054
41111
|
// TODO: check whether there are matchUps which are no longer possible to play
|
|
41055
|
-
//
|
|
41112
|
+
// In the first instance, matchUps which are explicitly scheduled on the court for times which are no longer available
|
|
41113
|
+
// NOTE: see dateAvailability.test.ts
|
|
41056
41114
|
if (courtMatchUps === null || courtMatchUps === void 0 ? void 0 : courtMatchUps.length) {
|
|
41057
|
-
|
|
41115
|
+
var appliedPolicies = (_b = getAppliedPolicies({
|
|
41116
|
+
tournamentRecord: tournamentRecord,
|
|
41117
|
+
})) === null || _b === void 0 ? void 0 : _b.appliedPolicies;
|
|
41118
|
+
var allowModificationWhenMatchUpsScheduled = force !== null && force !== void 0 ? force : (_d = (_c = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCHEDULING]) === null || _c === void 0 ? void 0 : _c.allowDeletionWithScoresPresent) === null || _d === void 0 ? void 0 : _d.courts;
|
|
41119
|
+
// Iterate through courtMatchUps and check that scheduledTime/scheduledDate still avilable
|
|
41120
|
+
var matchUpsWithInvalidScheduling = [];
|
|
41121
|
+
if (matchUpsWithInvalidScheduling.length) {
|
|
41122
|
+
if (allowModificationWhenMatchUpsScheduled) ;
|
|
41123
|
+
else {
|
|
41124
|
+
console.log('throw error: scheduled court matchUps', matchUpsWithInvalidScheduling.length);
|
|
41125
|
+
}
|
|
41126
|
+
}
|
|
41058
41127
|
}
|
|
41128
|
+
// TODO: In the second instance, if there is reduced aggregate court time matchUps scheduled on the affected dates (but not specific court)
|
|
41129
|
+
// would have scheduling impacts impacts
|
|
41059
41130
|
if (court) {
|
|
41060
41131
|
court.dateAvailability = dateAvailability;
|
|
41061
41132
|
if (!disableNotice && venue)
|
|
@@ -41361,7 +41432,7 @@ function addCourts$1(_a) {
|
|
|
41361
41432
|
|
|
41362
41433
|
function modifyVenue$1(_a) {
|
|
41363
41434
|
var e_1, _b;
|
|
41364
|
-
var _c, _d, _e, _f, _g;
|
|
41435
|
+
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
41365
41436
|
var tournamentRecord = _a.tournamentRecord, modifications = _a.modifications, venueId = _a.venueId, force = _a.force;
|
|
41366
41437
|
if (!tournamentRecord)
|
|
41367
41438
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
@@ -41369,6 +41440,10 @@ function modifyVenue$1(_a) {
|
|
|
41369
41440
|
return { error: INVALID_OBJECT };
|
|
41370
41441
|
if (!venueId)
|
|
41371
41442
|
return { error: MISSING_VENUE_ID };
|
|
41443
|
+
var appliedPolicies = (_c = getAppliedPolicies({
|
|
41444
|
+
tournamentRecord: tournamentRecord,
|
|
41445
|
+
})) === null || _c === void 0 ? void 0 : _c.appliedPolicies;
|
|
41446
|
+
var allowModificationWhenMatchUpsScheduled = force !== null && force !== void 0 ? force : (_e = (_d = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCHEDULING]) === null || _d === void 0 ? void 0 : _d.allowDeletionWithScoresPresent) === null || _e === void 0 ? void 0 : _e.venues;
|
|
41372
41447
|
var venueMatchUps = getScheduledVenueMatchUps({
|
|
41373
41448
|
tournamentRecord: tournamentRecord,
|
|
41374
41449
|
venueId: venueId,
|
|
@@ -41389,27 +41464,52 @@ function modifyVenue$1(_a) {
|
|
|
41389
41464
|
var _a;
|
|
41390
41465
|
return Object.assign(venue, (_a = {}, _a[attribute] = modifications[attribute], _a));
|
|
41391
41466
|
});
|
|
41392
|
-
var existingCourtIds = (
|
|
41393
|
-
var courtIdsToModify = ((
|
|
41467
|
+
var existingCourtIds = (_g = (_f = venue === null || venue === void 0 ? void 0 : venue.courts) === null || _f === void 0 ? void 0 : _f.map(function (court) { return court.courtId; })) !== null && _g !== void 0 ? _g : [];
|
|
41468
|
+
var courtIdsToModify = ((_h = modifications.courts) === null || _h === void 0 ? void 0 : _h.map(function (court) { return court.courtId; })) || [];
|
|
41394
41469
|
var courtIdsToDelete = existingCourtIds.filter(function (courtId) { return !courtIdsToModify.includes(courtId); });
|
|
41470
|
+
var matchUpsWithCourtId = [];
|
|
41395
41471
|
if (courtIdsToDelete.length) {
|
|
41396
|
-
var courtsToDelete = (
|
|
41472
|
+
var courtsToDelete = (_j = venue === null || venue === void 0 ? void 0 : venue.courts) === null || _j === void 0 ? void 0 : _j.filter(function (court) {
|
|
41397
41473
|
return courtIdsToDelete.includes(court.courtId);
|
|
41398
41474
|
});
|
|
41399
41475
|
var scheduleDeletionsCount = courtsToDelete === null || courtsToDelete === void 0 ? void 0 : courtsToDelete.map(function (court) {
|
|
41400
|
-
var
|
|
41476
|
+
var e_2, _a;
|
|
41477
|
+
var _b, _c, _d;
|
|
41401
41478
|
// check whether deleting court would remove schedule from any matchUps
|
|
41402
41479
|
var result = getScheduledCourtMatchUps({
|
|
41403
41480
|
courtId: court.courtId,
|
|
41404
41481
|
tournamentRecord: tournamentRecord,
|
|
41405
41482
|
venueMatchUps: venueMatchUps,
|
|
41406
41483
|
});
|
|
41407
|
-
|
|
41484
|
+
try {
|
|
41485
|
+
for (var _e = __values((_b = result.matchUps) !== null && _b !== void 0 ? _b : []), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
41486
|
+
var matchUp = _f.value;
|
|
41487
|
+
matchUpsWithCourtId.push({
|
|
41488
|
+
matchUpId: matchUp.matchUpId,
|
|
41489
|
+
drawId: matchUp.drawId,
|
|
41490
|
+
});
|
|
41491
|
+
}
|
|
41492
|
+
}
|
|
41493
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
41494
|
+
finally {
|
|
41495
|
+
try {
|
|
41496
|
+
if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
|
|
41497
|
+
}
|
|
41498
|
+
finally { if (e_2) throw e_2.error; }
|
|
41499
|
+
}
|
|
41500
|
+
return (_d = (_c = result.matchUps) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
|
|
41408
41501
|
}).reduce(function (a, b) { return a + b; });
|
|
41409
|
-
if (venue &&
|
|
41410
|
-
|
|
41502
|
+
if (venue &&
|
|
41503
|
+
(!scheduleDeletionsCount || allowModificationWhenMatchUpsScheduled)) {
|
|
41504
|
+
venue.courts = (_k = venue.courts) === null || _k === void 0 ? void 0 : _k.filter(function (court) {
|
|
41411
41505
|
return courtIdsToModify.includes(court.courtId);
|
|
41412
41506
|
});
|
|
41507
|
+
bulkScheduleMatchUps$1({
|
|
41508
|
+
schedule: { courtId: '', scheduledDate: '' },
|
|
41509
|
+
matchUpDetails: matchUpsWithCourtId,
|
|
41510
|
+
removePriorValues: true,
|
|
41511
|
+
tournamentRecord: tournamentRecord,
|
|
41512
|
+
});
|
|
41413
41513
|
}
|
|
41414
41514
|
else {
|
|
41415
41515
|
return deletionMessage({
|
|
@@ -41419,8 +41519,8 @@ function modifyVenue$1(_a) {
|
|
|
41419
41519
|
}
|
|
41420
41520
|
if (modifications.courts) {
|
|
41421
41521
|
try {
|
|
41422
|
-
for (var
|
|
41423
|
-
var court =
|
|
41522
|
+
for (var _l = __values(modifications.courts), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
41523
|
+
var court = _m.value;
|
|
41424
41524
|
var courtId = (court || {}).courtId;
|
|
41425
41525
|
var result_1 = modifyCourt$1({
|
|
41426
41526
|
modifications: court,
|
|
@@ -41445,7 +41545,7 @@ function modifyVenue$1(_a) {
|
|
|
41445
41545
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
41446
41546
|
finally {
|
|
41447
41547
|
try {
|
|
41448
|
-
if (
|
|
41548
|
+
if (_m && !_m.done && (_b = _l.return)) _b.call(_l);
|
|
41449
41549
|
}
|
|
41450
41550
|
finally { if (e_1) throw e_1.error; }
|
|
41451
41551
|
}
|
|
@@ -44528,8 +44628,8 @@ function setStageQualifiersCount(_a) {
|
|
|
44528
44628
|
}
|
|
44529
44629
|
|
|
44530
44630
|
function generateDrawTypeAndModifyDrawDefinition$1(params) {
|
|
44531
|
-
var _a;
|
|
44532
|
-
var
|
|
44631
|
+
var _a, _b;
|
|
44632
|
+
var _c = params || {}, _d = _c.modifyOriginal, modifyOriginal = _d === void 0 ? true : _d, _e = _c.stageSequence, stageSequence = _e === void 0 ? 1 : _e, isMock = _c.isMock;
|
|
44533
44633
|
var stack = 'generateDrawTypeAndModifyDrawDefinition';
|
|
44534
44634
|
if (!params.drawDefinition)
|
|
44535
44635
|
return decorateResult({
|
|
@@ -44599,7 +44699,7 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
|
|
|
44599
44699
|
}
|
|
44600
44700
|
var drawSize = params.drawSize || mainStageDrawPositionsCount;
|
|
44601
44701
|
Object.assign(params, definedAttributes({ drawSize: drawSize, matchUpType: matchUpType, tieFormat: tieFormat }));
|
|
44602
|
-
var
|
|
44702
|
+
var _f = getAllDrawMatchUps({ drawDefinition: drawDefinition }), matchUps = _f.matchUps, matchUpsMap = _f.matchUpsMap;
|
|
44603
44703
|
if (tieFormat) {
|
|
44604
44704
|
// if there were exiting matchUps, exclude them from this step
|
|
44605
44705
|
matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(function (matchUp) {
|
|
@@ -44610,7 +44710,10 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
|
|
|
44610
44710
|
});
|
|
44611
44711
|
}
|
|
44612
44712
|
var inContextDrawMatchUps = addGoesTo({ drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }).inContextDrawMatchUps;
|
|
44613
|
-
modifyDrawNotice({
|
|
44713
|
+
modifyDrawNotice({
|
|
44714
|
+
tournamentId: (_b = params.tournamentRecord) === null || _b === void 0 ? void 0 : _b.tournamentId,
|
|
44715
|
+
drawDefinition: drawDefinition,
|
|
44716
|
+
});
|
|
44614
44717
|
return __assign(__assign({ inContextDrawMatchUps: inContextDrawMatchUps, drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }, SUCCESS), { structures: structures, matchUps: matchUps, links: links });
|
|
44615
44718
|
}
|
|
44616
44719
|
|
|
@@ -48102,7 +48205,7 @@ function renameStructures$1(_a) {
|
|
|
48102
48205
|
}
|
|
48103
48206
|
|
|
48104
48207
|
function removeStructure(_a) {
|
|
48105
|
-
var _b, _c, _d;
|
|
48208
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
48106
48209
|
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, event = _a.event, force = _a.force;
|
|
48107
48210
|
if (typeof structureId !== 'string')
|
|
48108
48211
|
return { error: INVALID_VALUES };
|
|
@@ -48121,8 +48224,18 @@ function removeStructure(_a) {
|
|
|
48121
48224
|
var score = _a.score;
|
|
48122
48225
|
return scoreHasValue({ score: score });
|
|
48123
48226
|
});
|
|
48124
|
-
if (scoresPresent
|
|
48125
|
-
|
|
48227
|
+
if (scoresPresent) {
|
|
48228
|
+
var appliedPolicies = (_b = getAppliedPolicies({
|
|
48229
|
+
tournamentRecord: tournamentRecord,
|
|
48230
|
+
drawDefinition: drawDefinition,
|
|
48231
|
+
structure: structure,
|
|
48232
|
+
event: event,
|
|
48233
|
+
})) === null || _b === void 0 ? void 0 : _b.appliedPolicies;
|
|
48234
|
+
var allowDeletionWithScoresPresent = force ||
|
|
48235
|
+
((_d = (_c = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCORING]) === null || _c === void 0 ? void 0 : _c.allowDeletionWithScoresPresent) === null || _d === void 0 ? void 0 : _d.structures);
|
|
48236
|
+
if (!allowDeletionWithScoresPresent)
|
|
48237
|
+
return { error: SCORES_PRESENT };
|
|
48238
|
+
}
|
|
48126
48239
|
var mainStageSequence1 = structures.find(function (_a) {
|
|
48127
48240
|
var stage = _a.stage, stageSequence = _a.stageSequence;
|
|
48128
48241
|
return stage === MAIN && stageSequence === 1;
|
|
@@ -48139,7 +48252,6 @@ function removeStructure(_a) {
|
|
|
48139
48252
|
}
|
|
48140
48253
|
var structureIds = structures.map(extractAttributes('structureId'));
|
|
48141
48254
|
var removedMatchUpIds = [];
|
|
48142
|
-
var idsToRemove = [structureId];
|
|
48143
48255
|
var getTargetedStructureIds = function (structureId) {
|
|
48144
48256
|
var _a, _b;
|
|
48145
48257
|
return (_b = (_a = drawDefinition.links) === null || _a === void 0 ? void 0 : _a.map(function (link) {
|
|
@@ -48163,6 +48275,9 @@ function removeStructure(_a) {
|
|
|
48163
48275
|
? getQualifyingSourceStructureIds(id)
|
|
48164
48276
|
: getTargetedStructureIds(id));
|
|
48165
48277
|
});
|
|
48278
|
+
var idsToRemove = isMainStageSequence1
|
|
48279
|
+
? relatedStructureIdsMap.get(structureId)
|
|
48280
|
+
: [structureId];
|
|
48166
48281
|
var _loop_1 = function () {
|
|
48167
48282
|
var idBeingRemoved = idsToRemove.pop();
|
|
48168
48283
|
var structure_1 = findStructure({
|
|
@@ -48173,23 +48288,21 @@ function removeStructure(_a) {
|
|
|
48173
48288
|
var matchUpIds = getMatchUpIds(matchUps_1);
|
|
48174
48289
|
removedMatchUpIds.push.apply(removedMatchUpIds, __spreadArray([], __read(matchUpIds), false));
|
|
48175
48290
|
drawDefinition.links =
|
|
48176
|
-
((
|
|
48291
|
+
((_e = drawDefinition.links) === null || _e === void 0 ? void 0 : _e.filter(function (link) {
|
|
48177
48292
|
return link.source.structureId !== idBeingRemoved &&
|
|
48178
48293
|
link.target.structureId !== idBeingRemoved;
|
|
48179
48294
|
})) || [];
|
|
48180
48295
|
if (!isMainStageSequence1 ||
|
|
48181
48296
|
(isMainStageSequence1 && qualifyingStructureIds.length) ||
|
|
48182
48297
|
idBeingRemoved !== structureId) {
|
|
48183
|
-
drawDefinition.structures = ((
|
|
48298
|
+
drawDefinition.structures = ((_f = drawDefinition.structures) !== null && _f !== void 0 ? _f : []).filter(function (structure) {
|
|
48184
48299
|
if (idBeingRemoved && idBeingRemoved === structure.structureId)
|
|
48185
48300
|
removedStructureIds.push(idBeingRemoved);
|
|
48186
48301
|
return structure.structureId !== idBeingRemoved;
|
|
48187
48302
|
});
|
|
48188
48303
|
}
|
|
48189
48304
|
var targetedStructureIds = idBeingRemoved &&
|
|
48190
|
-
(
|
|
48191
|
-
// targetedStructureIdsMap[idBeingRemoved].filter(
|
|
48192
|
-
(_d = relatedStructureIdsMap.get(idBeingRemoved)) === null || _d === void 0 ? void 0 : _d.filter(function (id) {
|
|
48305
|
+
((_g = relatedStructureIdsMap.get(idBeingRemoved)) === null || _g === void 0 ? void 0 : _g.filter(function (id) {
|
|
48193
48306
|
// IMPORTANT: only delete MAIN stageSequence: 1 if specified to protect against DOUBLE_ELIMINATION scenario
|
|
48194
48307
|
return id !== (mainStageSequence1 === null || mainStageSequence1 === void 0 ? void 0 : mainStageSequence1.structureId) ||
|
|
48195
48308
|
structureId === mainStageSequence1.structureId;
|
|
@@ -48197,7 +48310,7 @@ function removeStructure(_a) {
|
|
|
48197
48310
|
if (targetedStructureIds === null || targetedStructureIds === void 0 ? void 0 : targetedStructureIds.length)
|
|
48198
48311
|
idsToRemove.push.apply(idsToRemove, __spreadArray([], __read(targetedStructureIds), false));
|
|
48199
48312
|
};
|
|
48200
|
-
while (idsToRemove.length) {
|
|
48313
|
+
while (idsToRemove === null || idsToRemove === void 0 ? void 0 : idsToRemove.length) {
|
|
48201
48314
|
_loop_1();
|
|
48202
48315
|
}
|
|
48203
48316
|
// now get all remaining matchUps in the draw
|
|
@@ -48214,6 +48327,8 @@ function removeStructure(_a) {
|
|
|
48214
48327
|
});
|
|
48215
48328
|
// if this is MAIN stageSequence: 1 there must be qualifying, return to empty state
|
|
48216
48329
|
if (isMainStageSequence1) {
|
|
48330
|
+
var mainStageSequence1MatchUpIds = (_j = ((_h = mainStageSequence1.matchUps) !== null && _h !== void 0 ? _h : [])) === null || _j === void 0 ? void 0 : _j.map(extractAttributes('matchUpId'));
|
|
48331
|
+
removedMatchUpIds.push.apply(removedMatchUpIds, __spreadArray([], __read(mainStageSequence1MatchUpIds), false));
|
|
48217
48332
|
mainStageSequence1.positionAssignments = [];
|
|
48218
48333
|
mainStageSequence1.seedAssignments = [];
|
|
48219
48334
|
mainStageSequence1.matchUps = [];
|
|
@@ -61127,17 +61242,17 @@ function getPositionAssignments(_a) {
|
|
|
61127
61242
|
};
|
|
61128
61243
|
}
|
|
61129
61244
|
|
|
61130
|
-
function deleteDrawDefinitions(
|
|
61131
|
-
var e_1,
|
|
61132
|
-
var _c, _d, _e;
|
|
61133
|
-
|
|
61134
|
-
if (!tournamentRecord)
|
|
61245
|
+
function deleteDrawDefinitions(params) {
|
|
61246
|
+
var e_1, _a;
|
|
61247
|
+
var _b, _c, _d, _e, _f, _g;
|
|
61248
|
+
if (!params.tournamentRecord)
|
|
61135
61249
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
61136
61250
|
var stack = 'deleteDrawDefinitions';
|
|
61137
|
-
|
|
61138
|
-
|
|
61139
|
-
|
|
61140
|
-
}
|
|
61251
|
+
var drawIds = (_b = params.drawIds) !== null && _b !== void 0 ? _b : [];
|
|
61252
|
+
var event = params.event;
|
|
61253
|
+
var _h = params.autoPublish, autoPublish = _h === void 0 ? true : _h, tournamentRecord = params.tournamentRecord, auditData = params.auditData, eventId = params.eventId, force = params.force;
|
|
61254
|
+
var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies;
|
|
61255
|
+
var policyDefinitions = __assign(__assign({}, appliedPolicies), params.policyDefinitions);
|
|
61141
61256
|
var drawId = Array.isArray(drawIds) ? drawIds[0] : undefined;
|
|
61142
61257
|
if (!event) {
|
|
61143
61258
|
var result = findEvent({ tournamentRecord: tournamentRecord, eventId: eventId, drawId: drawId });
|
|
@@ -61173,6 +61288,8 @@ function deleteDrawDefinitions(_a) {
|
|
|
61173
61288
|
var participantId = _a.participantId, drawPosition = _a.drawPosition, qualifier = _a.qualifier, bye = _a.bye;
|
|
61174
61289
|
return ({ bye: bye, qualifier: qualifier, drawPosition: drawPosition, participantId: participantId });
|
|
61175
61290
|
};
|
|
61291
|
+
var allowDeletionWithScoresPresent = force ||
|
|
61292
|
+
((_d = (_c = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCORING]) === null || _c === void 0 ? void 0 : _c.allowDeletionWithScoresPresent) === null || _d === void 0 ? void 0 : _d.drawDefinitions);
|
|
61176
61293
|
var drawIdsWithScoresPresent = [];
|
|
61177
61294
|
var filteredDrawDefinitions = event.drawDefinitions.filter(function (drawDefinition) {
|
|
61178
61295
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -61182,7 +61299,7 @@ function deleteDrawDefinitions(_a) {
|
|
|
61182
61299
|
var score = _a.score;
|
|
61183
61300
|
return scoreHasValue({ score: score });
|
|
61184
61301
|
});
|
|
61185
|
-
if (scoresPresent && !
|
|
61302
|
+
if (scoresPresent && !allowDeletionWithScoresPresent) {
|
|
61186
61303
|
drawIdsWithScoresPresent.push(drawDefinition.drawId);
|
|
61187
61304
|
return true;
|
|
61188
61305
|
}
|
|
@@ -61267,21 +61384,21 @@ function deleteDrawDefinitions(_a) {
|
|
|
61267
61384
|
checkSchedulingProfile({ tournamentRecord: tournamentRecord });
|
|
61268
61385
|
var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
|
|
61269
61386
|
var timeItem = getTimeItem({ element: event, itemType: itemType }).timeItem;
|
|
61270
|
-
var publishStatus = (
|
|
61387
|
+
var publishStatus = (_e = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _e === void 0 ? void 0 : _e[PUBLIC];
|
|
61271
61388
|
var publishedDrawsDeleted;
|
|
61272
61389
|
var _loop_1 = function (drawId_2) {
|
|
61273
|
-
var
|
|
61274
|
-
var drawPublished = (
|
|
61390
|
+
var _j;
|
|
61391
|
+
var drawPublished = (_f = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.drawIds) === null || _f === void 0 ? void 0 : _f.includes(drawId_2);
|
|
61275
61392
|
if (drawPublished) {
|
|
61276
61393
|
publishedDrawsDeleted = true;
|
|
61277
|
-
var updatedDrawIds = ((
|
|
61394
|
+
var updatedDrawIds = ((_g = publishStatus.drawIds) === null || _g === void 0 ? void 0 : _g.filter(function (publishedDrawId) { return publishedDrawId !== drawId_2; })) || [];
|
|
61278
61395
|
var timeItem_1 = {
|
|
61279
61396
|
itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
|
|
61280
|
-
itemValue: (
|
|
61281
|
-
|
|
61397
|
+
itemValue: (_j = {},
|
|
61398
|
+
_j[PUBLIC] = {
|
|
61282
61399
|
drawIds: updatedDrawIds,
|
|
61283
61400
|
},
|
|
61284
|
-
|
|
61401
|
+
_j),
|
|
61285
61402
|
};
|
|
61286
61403
|
var result = addEventTimeItem({ event: event, timeItem: timeItem_1 });
|
|
61287
61404
|
if (result.error)
|
|
@@ -61299,7 +61416,7 @@ function deleteDrawDefinitions(_a) {
|
|
|
61299
61416
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
61300
61417
|
finally {
|
|
61301
61418
|
try {
|
|
61302
|
-
if (drawIds_1_1 && !drawIds_1_1.done && (
|
|
61419
|
+
if (drawIds_1_1 && !drawIds_1_1.done && (_a = drawIds_1.return)) _a.call(drawIds_1);
|
|
61303
61420
|
}
|
|
61304
61421
|
finally { if (e_1) throw e_1.error; }
|
|
61305
61422
|
}
|
|
@@ -63087,7 +63204,7 @@ function resetVoluntaryConsolationStructure(_a) {
|
|
|
63087
63204
|
|
|
63088
63205
|
function deleteFlightProfileAndFlightDraws(_a) {
|
|
63089
63206
|
var _b;
|
|
63090
|
-
var _c = _a.autoPublish, autoPublish = _c === void 0 ? true : _c, tournamentRecord = _a.tournamentRecord, auditData = _a.auditData, event = _a.event;
|
|
63207
|
+
var _c = _a.autoPublish, autoPublish = _c === void 0 ? true : _c, tournamentRecord = _a.tournamentRecord, auditData = _a.auditData, event = _a.event, force = _a.force;
|
|
63091
63208
|
if (!tournamentRecord)
|
|
63092
63209
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
63093
63210
|
if (!event)
|
|
@@ -63105,6 +63222,7 @@ function deleteFlightProfileAndFlightDraws(_a) {
|
|
|
63105
63222
|
auditData: auditData,
|
|
63106
63223
|
drawIds: drawIds,
|
|
63107
63224
|
event: event,
|
|
63225
|
+
force: force,
|
|
63108
63226
|
});
|
|
63109
63227
|
if (result.error)
|
|
63110
63228
|
return result;
|
|
@@ -70625,7 +70743,7 @@ function generateVenues(_a) {
|
|
|
70625
70743
|
function modifyTournamentRecord(params) {
|
|
70626
70744
|
var e_1, _a, e_2, _b, _c, _d;
|
|
70627
70745
|
var _e, _f, _g;
|
|
70628
|
-
var _h = params.ratingsParameters, ratingsParameters$1 = _h === void 0 ? ratingsParameters : _h, _j = params.participantsProfile, participantsProfile = _j === void 0 ? {} : _j, matchUpStatusProfile = params.matchUpStatusProfile, completeAllMatchUps = params.completeAllMatchUps, autoEntryPositions = params.autoEntryPositions, hydrateCollections = params.hydrateCollections, randomWinningSide = params.randomWinningSide, schedulingProfile = params.schedulingProfile, tournamentRecord = params.tournamentRecord, eventProfiles = params.eventProfiles, venueProfiles = params.venueProfiles, autoSchedule = params.autoSchedule, drawProfiles = params.drawProfiles, uuids = params.uuids;
|
|
70746
|
+
var _h = params.ratingsParameters, ratingsParameters$1 = _h === void 0 ? ratingsParameters : _h, _j = params.participantsProfile, participantsProfile = _j === void 0 ? {} : _j, matchUpStatusProfile = params.matchUpStatusProfile, completeAllMatchUps = params.completeAllMatchUps, autoEntryPositions = params.autoEntryPositions, hydrateCollections = params.hydrateCollections, randomWinningSide = params.randomWinningSide, schedulingProfile = params.schedulingProfile, tournamentRecord = params.tournamentRecord, eventProfiles = params.eventProfiles, periodLength = params.periodLength, venueProfiles = params.venueProfiles, autoSchedule = params.autoSchedule, drawProfiles = params.drawProfiles, uuids = params.uuids;
|
|
70629
70747
|
if (!tournamentRecord)
|
|
70630
70748
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
70631
70749
|
var allUniqueParticipantIds = [];
|
|
@@ -70832,7 +70950,10 @@ function modifyTournamentRecord(params) {
|
|
|
70832
70950
|
if (autoSchedule) {
|
|
70833
70951
|
var tournamentId = tournamentRecord.tournamentId;
|
|
70834
70952
|
var tournamentRecords_1 = (_d = {}, _d[tournamentId] = tournamentRecord, _d);
|
|
70835
|
-
schedulerResult = scheduleProfileRounds({
|
|
70953
|
+
schedulerResult = scheduleProfileRounds({
|
|
70954
|
+
tournamentRecords: tournamentRecords_1,
|
|
70955
|
+
periodLength: periodLength,
|
|
70956
|
+
});
|
|
70836
70957
|
}
|
|
70837
70958
|
}
|
|
70838
70959
|
var totalParticipantsCount = tournamentRecord.participants.length;
|
|
@@ -70957,7 +71078,7 @@ var mockTournamentNames = [
|
|
|
70957
71078
|
function generateTournamentRecord(params) {
|
|
70958
71079
|
var e_1, _a, _b, e_2, _c, e_3, _d, _e;
|
|
70959
71080
|
var tournamentAttributes = params.tournamentAttributes, startDate = params.startDate, endDate = params.endDate;
|
|
70960
|
-
var _f = params.tournamentName, tournamentName = _f === void 0 ? randomPop(mockTournamentNames) : _f, _g = params.ratingsParameters, ratingsParameters$1 = _g === void 0 ? ratingsParameters : _g, scheduleCompletedMatchUps = params.scheduleCompletedMatchUps, tournamentExtensions = params.tournamentExtensions, matchUpStatusProfile = params.matchUpStatusProfile, completeAllMatchUps = params.completeAllMatchUps, participantsProfile = params.participantsProfile, autoEntryPositions = params.autoEntryPositions, hydrateCollections = params.hydrateCollections, randomWinningSide = params.randomWinningSide, policyDefinitions = params.policyDefinitions, schedulingProfile = params.schedulingProfile, autoSchedule = params.autoSchedule, eventProfiles = params.eventProfiles, venueProfiles = params.venueProfiles, drawProfiles = params.drawProfiles, uuids = params.uuids;
|
|
71081
|
+
var _f = params.tournamentName, tournamentName = _f === void 0 ? randomPop(mockTournamentNames) : _f, _g = params.ratingsParameters, ratingsParameters$1 = _g === void 0 ? ratingsParameters : _g, scheduleCompletedMatchUps = params.scheduleCompletedMatchUps, tournamentExtensions = params.tournamentExtensions, matchUpStatusProfile = params.matchUpStatusProfile, completeAllMatchUps = params.completeAllMatchUps, participantsProfile = params.participantsProfile, autoEntryPositions = params.autoEntryPositions, hydrateCollections = params.hydrateCollections, randomWinningSide = params.randomWinningSide, policyDefinitions = params.policyDefinitions, schedulingProfile = params.schedulingProfile, periodLength = params.periodLength, autoSchedule = params.autoSchedule, eventProfiles = params.eventProfiles, venueProfiles = params.venueProfiles, drawProfiles = params.drawProfiles, uuids = params.uuids;
|
|
70961
71082
|
if ((startDate && !isValidDateString(startDate)) ||
|
|
70962
71083
|
(endDate && !isValidDateString(endDate)))
|
|
70963
71084
|
return { error: INVALID_DATE };
|
|
@@ -71118,6 +71239,7 @@ function generateTournamentRecord(params) {
|
|
|
71118
71239
|
schedulerResult = scheduleProfileRounds({
|
|
71119
71240
|
scheduleCompletedMatchUps: scheduleCompletedMatchUps,
|
|
71120
71241
|
tournamentRecords: tournamentRecords,
|
|
71242
|
+
periodLength: periodLength,
|
|
71121
71243
|
});
|
|
71122
71244
|
}
|
|
71123
71245
|
}
|