tods-competition-factory 0.87.0 → 0.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tods-competition-factory.development.cjs.js +789 -399
- 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/dist/tods-competition-factory.production.esm.min.js +1 -1
- package/dist/tods-competition-factory.production.esm.min.js.map +1 -1
- package/package.json +5 -5
|
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
function factoryVersion() {
|
|
252
|
-
return '0.
|
|
252
|
+
return '0.89.0';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const FORMAT_STANDARD = 'SET3-S:6/TB7'; // Best of 3 Tiebreak Sets to 6
|
|
@@ -2453,7 +2453,6 @@ const SEEDING$1 = 'SEEDING'; // 'SCALE.SEEDING'
|
|
|
2453
2453
|
|
|
2454
2454
|
const PUBLISH = 'PUBLISH';
|
|
2455
2455
|
const PUBLIC = 'PUBLIC';
|
|
2456
|
-
const HIDDEN = 'HIDDEN';
|
|
2457
2456
|
const STATUS$1 = 'STATUS';
|
|
2458
2457
|
const RETRIEVAL = 'RETRIEVAL';
|
|
2459
2458
|
const OTHER$3 = 'other';
|
|
@@ -2464,7 +2463,6 @@ const timeItemConstants = {
|
|
|
2464
2463
|
CHECK_IN,
|
|
2465
2464
|
CHECK_OUT,
|
|
2466
2465
|
END_TIME,
|
|
2467
|
-
HIDDEN,
|
|
2468
2466
|
MEDICAL: MEDICAL$1,
|
|
2469
2467
|
OTHER: OTHER$3,
|
|
2470
2468
|
PENALTY: PENALTY$1,
|
|
@@ -7628,7 +7626,7 @@ var tieFormatName$3 = "USTA_INTERSECTIONAL";
|
|
|
7628
7626
|
var winCriteria$3 = {
|
|
7629
7627
|
valueGoal: 8
|
|
7630
7628
|
};
|
|
7631
|
-
var
|
|
7629
|
+
var USTA_INTERSECTIONAL_TIE_FORMAT = {
|
|
7632
7630
|
collectionDefinitions: collectionDefinitions$3,
|
|
7633
7631
|
tieFormatName: tieFormatName$3,
|
|
7634
7632
|
winCriteria: winCriteria$3
|
|
@@ -7668,7 +7666,7 @@ var tieFormatName$2 = "USTA_LEVEL_1";
|
|
|
7668
7666
|
var winCriteria$2 = {
|
|
7669
7667
|
valueGoal: 10
|
|
7670
7668
|
};
|
|
7671
|
-
var
|
|
7669
|
+
var USTA_LEVEL_1_TIE_FORMAT = {
|
|
7672
7670
|
collectionDefinitions: collectionDefinitions$2,
|
|
7673
7671
|
tieFormatName: tieFormatName$2,
|
|
7674
7672
|
winCriteria: winCriteria$2
|
|
@@ -7701,7 +7699,7 @@ var tieFormatName$1 = "USTA_SOUTHERN_LEVEL_5";
|
|
|
7701
7699
|
var winCriteria$1 = {
|
|
7702
7700
|
valueGoal: 8
|
|
7703
7701
|
};
|
|
7704
|
-
var
|
|
7702
|
+
var USTA_SOUTHERN_LEVEL_5_TIE_FORMAT = {
|
|
7705
7703
|
collectionDefinitions: collectionDefinitions$1,
|
|
7706
7704
|
tieFormatName: tieFormatName$1,
|
|
7707
7705
|
winCriteria: winCriteria$1
|
|
@@ -7748,7 +7746,7 @@ var tieFormatName = "USTA_ZONAL";
|
|
|
7748
7746
|
var winCriteria = {
|
|
7749
7747
|
valueGoal: 10
|
|
7750
7748
|
};
|
|
7751
|
-
var
|
|
7749
|
+
var USTA_ZONAL_TIE_FORMAT = {
|
|
7752
7750
|
collectionDefinitions: collectionDefinitions,
|
|
7753
7751
|
tieFormatName: tieFormatName,
|
|
7754
7752
|
winCriteria: winCriteria
|
|
@@ -7761,10 +7759,10 @@ const tieFormats = {
|
|
|
7761
7759
|
DOMINANT_DUO: DOMINANT_DUO_TIE_FORMAT,
|
|
7762
7760
|
LAVER_CUP: LAVER_CUP_TIE_FORMAT,
|
|
7763
7761
|
TEAM_DOUBLES_3_AGGREGATION: TEAM_AGGREGATION_TIE_FORMAT,
|
|
7764
|
-
USTA_INTERSECTIONAL:
|
|
7765
|
-
USTA_LEVEL_1:
|
|
7766
|
-
USTA_SOUTHERN_LEVEL_5:
|
|
7767
|
-
USTA_ZONAL:
|
|
7762
|
+
USTA_INTERSECTIONAL: USTA_INTERSECTIONAL_TIE_FORMAT,
|
|
7763
|
+
USTA_LEVEL_1: USTA_LEVEL_1_TIE_FORMAT,
|
|
7764
|
+
USTA_SOUTHERN_LEVEL_5: USTA_SOUTHERN_LEVEL_5_TIE_FORMAT,
|
|
7765
|
+
USTA_ZONAL: USTA_ZONAL_TIE_FORMAT
|
|
7768
7766
|
};
|
|
7769
7767
|
|
|
7770
7768
|
const POLICY_AVOIDANCE_COUNTRY = {
|
|
@@ -9585,6 +9583,8 @@ const MODIFY_PARTICIPANTS = 'modifyParticipants';
|
|
|
9585
9583
|
const MODIFY_VENUE = 'modifyVenue';
|
|
9586
9584
|
const PUBLISH_EVENT = 'publishEvent';
|
|
9587
9585
|
const UNPUBLISH_EVENT = 'unPublishEvent';
|
|
9586
|
+
const PUBLISH_EVENT_SEEDING = 'publishEventSeeding';
|
|
9587
|
+
const UNPUBLISH_EVENT_SEEDING = 'unPublishEventSeeding';
|
|
9588
9588
|
const topicConstants = {
|
|
9589
9589
|
ADD_DRAW_DEFINITION,
|
|
9590
9590
|
ADD_MATCHUPS,
|
|
@@ -9599,7 +9599,10 @@ const topicConstants = {
|
|
|
9599
9599
|
MODIFY_MATCHUP,
|
|
9600
9600
|
MODIFY_PARTICIPANTS,
|
|
9601
9601
|
MODIFY_VENUE,
|
|
9602
|
-
PUBLISH_EVENT
|
|
9602
|
+
PUBLISH_EVENT,
|
|
9603
|
+
UNPUBLISH_EVENT,
|
|
9604
|
+
PUBLISH_EVENT_SEEDING,
|
|
9605
|
+
UNPUBLISH_EVENT_SEEDING
|
|
9603
9606
|
};
|
|
9604
9607
|
|
|
9605
9608
|
function drawUpdatedAt(drawDefinition, structureIds) {
|
|
@@ -11709,6 +11712,7 @@ function getAllStructureMatchUps({
|
|
|
11709
11712
|
|
|
11710
11713
|
let collectionPositionMatchUps = {},
|
|
11711
11714
|
roundMatchUps = {};
|
|
11715
|
+
tournamentParticipants = tournamentParticipants || (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants);
|
|
11712
11716
|
|
|
11713
11717
|
if (!structure) {
|
|
11714
11718
|
return {
|
|
@@ -11765,7 +11769,6 @@ function getAllStructureMatchUps({
|
|
|
11765
11769
|
seedAssignments: structureSeedAssignments
|
|
11766
11770
|
} = getStructureSeedAssignments({
|
|
11767
11771
|
drawDefinition,
|
|
11768
|
-
matchUpsMap,
|
|
11769
11772
|
structure
|
|
11770
11773
|
}); // enables passing in seedAssignments rather than using structureSeedAssignments
|
|
11771
11774
|
|
|
@@ -12976,11 +12979,11 @@ function nextRoundMatchUp({
|
|
|
12976
12979
|
}
|
|
12977
12980
|
|
|
12978
12981
|
function getTargetMatchUp({
|
|
12979
|
-
|
|
12982
|
+
sourceRoundMatchUpCount,
|
|
12980
12983
|
inContextDrawMatchUps,
|
|
12981
|
-
targetLink,
|
|
12982
12984
|
sourceRoundPosition,
|
|
12983
|
-
|
|
12985
|
+
drawDefinition,
|
|
12986
|
+
targetLink
|
|
12984
12987
|
}) {
|
|
12985
12988
|
if (!targetLink) return {
|
|
12986
12989
|
error: MISSING_TARGET_LINK
|
|
@@ -17693,7 +17696,6 @@ function advanceWinner({
|
|
|
17693
17696
|
matchUpId: winnerMatchUp.matchUpId,
|
|
17694
17697
|
inContextDrawMatchUps,
|
|
17695
17698
|
drawDefinition,
|
|
17696
|
-
iterative: 'brightmagenta',
|
|
17697
17699
|
matchUpsMap
|
|
17698
17700
|
});
|
|
17699
17701
|
} else if (drawPositionIsBye) {
|
|
@@ -17805,21 +17807,20 @@ function getUpdatedDrawPositions({
|
|
|
17805
17807
|
|
|
17806
17808
|
function getWalkoverWinningSide({
|
|
17807
17809
|
inContextDrawMatchUps,
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
+
drawPosition,
|
|
17811
|
+
matchUpId
|
|
17810
17812
|
}) {
|
|
17811
17813
|
// determine which sideNumber { drawPosition } will be and assign winningSide
|
|
17812
17814
|
// NOTE: at present this is dependent on presence of .winnerMatchUpId and .loserMatchUpId
|
|
17813
17815
|
// TODO: reusable function that will be able to use position targeting using links
|
|
17814
17816
|
// which will need to filter by previous round then get positionTargets for each matchUp in the round
|
|
17815
|
-
// sourceMatchUps MUST be sorted by roundPosition
|
|
17816
17817
|
const sourceMatchUps = inContextDrawMatchUps.filter(({
|
|
17817
17818
|
winnerMatchUpId,
|
|
17818
17819
|
loserMatchUpId
|
|
17819
|
-
}) => loserMatchUpId === matchUpId || winnerMatchUpId === matchUpId)
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17820
|
+
}) => loserMatchUpId === matchUpId || winnerMatchUpId === matchUpId) // sourceMatchUps MUST be sorted by roundPosition
|
|
17821
|
+
.sort((a, b) => a.roundPosition - b.roundPosition);
|
|
17822
|
+
const matchUp = inContextDrawMatchUps.find(matchUp => matchUp.matchUpId === matchUpId);
|
|
17823
|
+
const feedRound = matchUp.feedRound;
|
|
17823
17824
|
return feedRound ? 1 : sourceMatchUps.reduce((sideNumber, sourceMatchUp, index) => {
|
|
17824
17825
|
var _sourceMatchUp$drawPo;
|
|
17825
17826
|
|
|
@@ -18134,9 +18135,12 @@ function conditionallyAdvanceDrawPosition(params) {
|
|
|
18134
18135
|
if (result.error) return result; // when there is an existing WO/WO created WALKOVER it is replaced
|
|
18135
18136
|
// with a DOUBLE_WALKOVER and move on to advancing from this position
|
|
18136
18137
|
|
|
18137
|
-
if (existingWalkover)
|
|
18138
|
-
|
|
18139
|
-
|
|
18138
|
+
if (existingWalkover) {
|
|
18139
|
+
return doubleWalkoverAdvancement({ ...params,
|
|
18140
|
+
targetData
|
|
18141
|
+
});
|
|
18142
|
+
}
|
|
18143
|
+
|
|
18140
18144
|
if (!nextWinnerMatchUp) return { ...SUCCESS
|
|
18141
18145
|
}; // any remaining drawPosition in winnerMatchUp should be advanced
|
|
18142
18146
|
|
|
@@ -18162,23 +18166,28 @@ function conditionallyAdvanceDrawPosition(params) {
|
|
|
18162
18166
|
});
|
|
18163
18167
|
|
|
18164
18168
|
if (nextWinnerMatchUpHasDrawPosition) {
|
|
18165
|
-
// if the next winnerMatchUp already has a drawPosition
|
|
18169
|
+
const nextDrawPositionToAdvance = nextWinnerMatchUpDrawPositions.filter(Boolean)[0]; // if the next winnerMatchUp already has a drawPosition
|
|
18170
|
+
|
|
18171
|
+
const winningSide = getWalkoverWinningSide({
|
|
18172
|
+
drawPosition: nextDrawPositionToAdvance,
|
|
18173
|
+
matchUpId: noContextNextWinnerMatchUp.matchUpId,
|
|
18174
|
+
inContextDrawMatchUps
|
|
18175
|
+
});
|
|
18166
18176
|
const result = modifyMatchUpScore({
|
|
18167
18177
|
matchUpId: noContextNextWinnerMatchUp.matchUpId,
|
|
18168
18178
|
matchUp: noContextNextWinnerMatchUp,
|
|
18169
18179
|
matchUpStatus: WALKOVER$1,
|
|
18170
18180
|
removeScore: true,
|
|
18171
18181
|
drawDefinition,
|
|
18172
|
-
winningSide
|
|
18182
|
+
winningSide
|
|
18173
18183
|
});
|
|
18174
18184
|
if (result.error) return result;
|
|
18175
|
-
const drawPositionToAdvance = nextWinnerMatchUpDrawPositions.filter(Boolean)[0];
|
|
18176
18185
|
return advanceDrawPosition({
|
|
18177
|
-
drawPositionToAdvance,
|
|
18186
|
+
drawPositionToAdvance: nextDrawPositionToAdvance,
|
|
18187
|
+
matchUpId: noContextNextWinnerMatchUp.matchUpId,
|
|
18178
18188
|
inContextDrawMatchUps,
|
|
18179
18189
|
drawDefinition,
|
|
18180
|
-
matchUpsMap
|
|
18181
|
-
matchUpId: noContextNextWinnerMatchUp.matchUpId
|
|
18190
|
+
matchUpsMap
|
|
18182
18191
|
});
|
|
18183
18192
|
} else if (nextWinnerMatchUp.matchUpStatus === WALKOVER$1) {
|
|
18184
18193
|
// if the next winnerMatchUp is a doubleWalkover
|
|
@@ -20252,20 +20261,21 @@ function isActiveDownstream(params) {
|
|
|
20252
20261
|
});
|
|
20253
20262
|
let winnerTargetData = winnerMatchUp && positionTargets({
|
|
20254
20263
|
matchUpId: winnerMatchUp.matchUpId,
|
|
20255
|
-
|
|
20256
|
-
|
|
20264
|
+
inContextDrawMatchUps,
|
|
20265
|
+
drawDefinition
|
|
20257
20266
|
});
|
|
20258
20267
|
const loserActive = loserTargetData && isActiveDownstream({
|
|
20259
20268
|
inContextDrawMatchUps,
|
|
20260
|
-
|
|
20261
|
-
|
|
20269
|
+
targetData: loserTargetData,
|
|
20270
|
+
drawDefinition
|
|
20262
20271
|
});
|
|
20263
20272
|
const winnerActive = winnerTargetData && isActiveDownstream({
|
|
20264
20273
|
inContextDrawMatchUps,
|
|
20265
|
-
|
|
20266
|
-
|
|
20274
|
+
targetData: winnerTargetData,
|
|
20275
|
+
drawDefinition
|
|
20267
20276
|
});
|
|
20268
|
-
|
|
20277
|
+
const isActive = !!(winnerActive || loserActive);
|
|
20278
|
+
return isActive;
|
|
20269
20279
|
}
|
|
20270
20280
|
|
|
20271
20281
|
/**
|
|
@@ -20527,7 +20537,7 @@ function setMatchUpStatus$2(params) {
|
|
|
20527
20537
|
matchUpsMap,
|
|
20528
20538
|
event
|
|
20529
20539
|
});
|
|
20530
|
-
const tieFormat = (dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat) || undefined;
|
|
20540
|
+
const tieFormat = (dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.tieFormat) || (structure === null || structure === void 0 ? void 0 : structure.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat) || undefined;
|
|
20531
20541
|
const {
|
|
20532
20542
|
projectedWinningSide
|
|
20533
20543
|
} = getProjectedDualWinningSide({
|
|
@@ -22694,6 +22704,71 @@ function getRelevantParticipantIdsMap({
|
|
|
22694
22704
|
};
|
|
22695
22705
|
}
|
|
22696
22706
|
|
|
22707
|
+
function getAccessorValue({
|
|
22708
|
+
element,
|
|
22709
|
+
accessor
|
|
22710
|
+
}) {
|
|
22711
|
+
if (typeof accessor !== 'string') return {
|
|
22712
|
+
values: []
|
|
22713
|
+
};
|
|
22714
|
+
const targetElement = makeDeepCopy(element);
|
|
22715
|
+
const attributes = accessor.split('.');
|
|
22716
|
+
let value,
|
|
22717
|
+
values = [];
|
|
22718
|
+
processKeys({
|
|
22719
|
+
targetElement,
|
|
22720
|
+
attributes
|
|
22721
|
+
});
|
|
22722
|
+
const result = {
|
|
22723
|
+
value
|
|
22724
|
+
};
|
|
22725
|
+
if (values.length) result.values = values;
|
|
22726
|
+
return result;
|
|
22727
|
+
|
|
22728
|
+
function processKeys({
|
|
22729
|
+
targetElement,
|
|
22730
|
+
attributes = [],
|
|
22731
|
+
significantCharacters
|
|
22732
|
+
}) {
|
|
22733
|
+
for (const [index, attribute] of attributes.entries()) {
|
|
22734
|
+
if (targetElement && targetElement[attribute]) {
|
|
22735
|
+
if (Array.isArray(targetElement[attribute])) {
|
|
22736
|
+
const values = targetElement[attribute];
|
|
22737
|
+
const remainingKeys = attributes.slice(index);
|
|
22738
|
+
values.forEach(nestedTarget => processKeys({
|
|
22739
|
+
targetElement: nestedTarget,
|
|
22740
|
+
attributes: remainingKeys
|
|
22741
|
+
}));
|
|
22742
|
+
} else {
|
|
22743
|
+
targetElement = targetElement[attribute];
|
|
22744
|
+
checkValue({
|
|
22745
|
+
targetElement,
|
|
22746
|
+
index
|
|
22747
|
+
});
|
|
22748
|
+
}
|
|
22749
|
+
}
|
|
22750
|
+
}
|
|
22751
|
+
|
|
22752
|
+
function checkValue({
|
|
22753
|
+
targetElement,
|
|
22754
|
+
index
|
|
22755
|
+
}) {
|
|
22756
|
+
if (targetElement && index === attributes.length - 1 && ['string', 'number'].includes(typeof targetElement)) {
|
|
22757
|
+
const extractedValue = significantCharacters ? targetElement.slice(0, significantCharacters) : targetElement;
|
|
22758
|
+
|
|
22759
|
+
if (value) {
|
|
22760
|
+
if (!values.includes(extractedValue)) {
|
|
22761
|
+
values.push(extractedValue);
|
|
22762
|
+
}
|
|
22763
|
+
} else {
|
|
22764
|
+
value = extractedValue;
|
|
22765
|
+
values.push(extractedValue);
|
|
22766
|
+
}
|
|
22767
|
+
}
|
|
22768
|
+
}
|
|
22769
|
+
}
|
|
22770
|
+
}
|
|
22771
|
+
|
|
22697
22772
|
const SCALE = 'SCALE';
|
|
22698
22773
|
const RATING = 'RATING';
|
|
22699
22774
|
const RANKING = 'RANKING';
|
|
@@ -22705,10 +22780,67 @@ const scaleConstants = {
|
|
|
22705
22780
|
SEEDING
|
|
22706
22781
|
};
|
|
22707
22782
|
|
|
22783
|
+
function participantScaleItem({
|
|
22784
|
+
requireTimeStamp,
|
|
22785
|
+
scaleAttributes,
|
|
22786
|
+
participant
|
|
22787
|
+
}) {
|
|
22788
|
+
if (!participant) return {
|
|
22789
|
+
error: MISSING_PARTICIPANT
|
|
22790
|
+
};
|
|
22791
|
+
if (typeof scaleAttributes !== 'object') return {
|
|
22792
|
+
error: INVALID_VALUES
|
|
22793
|
+
};
|
|
22794
|
+
if (!participant.timeItems) participant.timeItems = [];
|
|
22795
|
+
|
|
22796
|
+
if (participant && Array.isArray(participant.timeItems)) {
|
|
22797
|
+
const {
|
|
22798
|
+
accessor,
|
|
22799
|
+
scaleType,
|
|
22800
|
+
eventType,
|
|
22801
|
+
scaleName
|
|
22802
|
+
} = scaleAttributes;
|
|
22803
|
+
const filterType = [SCALE, scaleType, eventType, scaleName].join('.');
|
|
22804
|
+
const filteredTimeItems = participant.timeItems.filter(timeItem => (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemType) === filterType).filter(timeItem => !requireTimeStamp || (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemDate)).sort((a, b) => new Date(a.createdAt || undefined) - new Date(b.createdAt || undefined));
|
|
22805
|
+
const timeItem = filteredTimeItems.pop();
|
|
22806
|
+
|
|
22807
|
+
if (timeItem) {
|
|
22808
|
+
const [itemSubject, scaleType, eventType, scaleName] = timeItem.itemType.split('.');
|
|
22809
|
+
if (itemSubject !== SCALE) return {
|
|
22810
|
+
error: INVALID_SCALE_ITEM
|
|
22811
|
+
};
|
|
22812
|
+
const accessorValue = accessor && getAccessorValue({
|
|
22813
|
+
element: timeItem.itemValue,
|
|
22814
|
+
accessor
|
|
22815
|
+
});
|
|
22816
|
+
const scaleValue = accessor ? accessorValue.value : timeItem.itemValue;
|
|
22817
|
+
const scaleItem = {
|
|
22818
|
+
scaleDate: timeItem.itemDate,
|
|
22819
|
+
scaleName,
|
|
22820
|
+
scaleType,
|
|
22821
|
+
eventType,
|
|
22822
|
+
scaleValue
|
|
22823
|
+
};
|
|
22824
|
+
return {
|
|
22825
|
+
scaleItem
|
|
22826
|
+
};
|
|
22827
|
+
} else {
|
|
22828
|
+
return {
|
|
22829
|
+
error: SCALE_ITEM_NOT_FOUND
|
|
22830
|
+
};
|
|
22831
|
+
}
|
|
22832
|
+
}
|
|
22833
|
+
|
|
22834
|
+
return {
|
|
22835
|
+
error: MISSING_PARTICIPANT
|
|
22836
|
+
};
|
|
22837
|
+
}
|
|
22838
|
+
|
|
22708
22839
|
function addParticipantContext(params) {
|
|
22709
22840
|
var _params$tournamentPar;
|
|
22710
22841
|
|
|
22711
22842
|
const participantIdsWithConflicts = [];
|
|
22843
|
+
const eventsPublishStatuses = {};
|
|
22712
22844
|
const drawSizes = {};
|
|
22713
22845
|
const participantIdMap = {};
|
|
22714
22846
|
|
|
@@ -22803,7 +22935,7 @@ function addParticipantContext(params) {
|
|
|
22803
22935
|
|
|
22804
22936
|
// loop through all filtered events and capture events played
|
|
22805
22937
|
(_params$tournamentEve = params.tournamentEvents) === null || _params$tournamentEve === void 0 ? void 0 : _params$tournamentEve.forEach(rawEvent => {
|
|
22806
|
-
var _event$drawDefinition, _eventInfo$_flightPro, _eventInfo$_flightPro2;
|
|
22938
|
+
var _timeItem$itemValue, _event$drawDefinition, _eventInfo$_flightPro, _eventInfo$_flightPro2;
|
|
22807
22939
|
|
|
22808
22940
|
const event = makeDeepCopy(rawEvent, true, true);
|
|
22809
22941
|
const {
|
|
@@ -22820,7 +22952,33 @@ function addParticipantContext(params) {
|
|
|
22820
22952
|
};
|
|
22821
22953
|
const extensionKeys = event && Object.keys(event).filter(key => key[0] === '_');
|
|
22822
22954
|
extensionKeys === null || extensionKeys === void 0 ? void 0 : extensionKeys.forEach(extensionKey => eventInfo[extensionKey] = event[extensionKey]);
|
|
22823
|
-
const eventEntries = event.entries || [];
|
|
22955
|
+
const eventEntries = event.entries || [];
|
|
22956
|
+
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
22957
|
+
const {
|
|
22958
|
+
timeItem
|
|
22959
|
+
} = getEventTimeItem({
|
|
22960
|
+
itemType,
|
|
22961
|
+
event
|
|
22962
|
+
});
|
|
22963
|
+
|
|
22964
|
+
if (timeItem !== null && timeItem !== void 0 && (_timeItem$itemValue = timeItem.itemValue) !== null && _timeItem$itemValue !== void 0 && _timeItem$itemValue.PUBLIC) {
|
|
22965
|
+
const {
|
|
22966
|
+
drawIds: publishedDrawIds = [],
|
|
22967
|
+
seeding
|
|
22968
|
+
} = timeItem.itemValue.PUBLIC || {};
|
|
22969
|
+
const publishedSeeding = {
|
|
22970
|
+
published: undefined,
|
|
22971
|
+
// seeding can be present for all entries in an event when no flights have been defined
|
|
22972
|
+
drawIds: [] // seeding can be specific to drawIds
|
|
22973
|
+
|
|
22974
|
+
};
|
|
22975
|
+
if (seeding) Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
|
|
22976
|
+
eventsPublishStatuses[eventId] = {
|
|
22977
|
+
publishedDrawIds,
|
|
22978
|
+
publishedSeeding
|
|
22979
|
+
};
|
|
22980
|
+
} // don't allow system extensions to be copied to participants
|
|
22981
|
+
|
|
22824
22982
|
|
|
22825
22983
|
const disallowedConstants = [].concat(...Object.values(extensionConstants));
|
|
22826
22984
|
const disallowedKeys = disallowedConstants.map(constant => `_${constant}`);
|
|
@@ -22982,8 +23140,9 @@ function addParticipantContext(params) {
|
|
|
22982
23140
|
scheduleConflicts,
|
|
22983
23141
|
scheduleItems
|
|
22984
23142
|
} = annotateParticipant({ ...params,
|
|
22985
|
-
|
|
22986
|
-
participantIdMap
|
|
23143
|
+
eventsPublishStatuses,
|
|
23144
|
+
participantIdMap,
|
|
23145
|
+
participant
|
|
22987
23146
|
});
|
|
22988
23147
|
|
|
22989
23148
|
if (params.withSignInStatus) {
|
|
@@ -23259,15 +23418,18 @@ function addParticipantContext(params) {
|
|
|
23259
23418
|
}
|
|
23260
23419
|
|
|
23261
23420
|
return {
|
|
23262
|
-
participantIdsWithConflicts
|
|
23421
|
+
participantIdsWithConflicts,
|
|
23422
|
+
eventsPublishStatuses
|
|
23263
23423
|
};
|
|
23264
23424
|
}
|
|
23265
23425
|
|
|
23266
23426
|
function annotateParticipant({
|
|
23427
|
+
eventsPublishStatuses,
|
|
23267
23428
|
withEvents = true,
|
|
23268
23429
|
withDraws = true,
|
|
23269
23430
|
participantIdMap,
|
|
23270
23431
|
scheduleAnalysis,
|
|
23432
|
+
usePublishState,
|
|
23271
23433
|
withStatistics,
|
|
23272
23434
|
withOpponents,
|
|
23273
23435
|
withMatchUps,
|
|
@@ -23333,8 +23495,95 @@ function annotateParticipant({
|
|
|
23333
23495
|
};
|
|
23334
23496
|
const participantDraws = Object.values(draws);
|
|
23335
23497
|
const participantEvents = Object.values(events);
|
|
23336
|
-
|
|
23337
|
-
|
|
23498
|
+
|
|
23499
|
+
if (withDraws && participantDraws) {
|
|
23500
|
+
participant.draws = participantDraws;
|
|
23501
|
+
|
|
23502
|
+
for (const participantDraw of participantDraws) {
|
|
23503
|
+
var _result;
|
|
23504
|
+
|
|
23505
|
+
const event = participantEvents === null || participantEvents === void 0 ? void 0 : participantEvents.find(e => e.eventId === participantDraw.eventId);
|
|
23506
|
+
const {
|
|
23507
|
+
categoryName,
|
|
23508
|
+
ageCategoryCode
|
|
23509
|
+
} = (event === null || event === void 0 ? void 0 : event.category) || {};
|
|
23510
|
+
let seedValue;
|
|
23511
|
+
let result = participantScaleItem({
|
|
23512
|
+
scaleAttributes: {
|
|
23513
|
+
scaleType: SEEDING,
|
|
23514
|
+
scaleName: participantDraw.drawId,
|
|
23515
|
+
eventType: event === null || event === void 0 ? void 0 : event.eventType
|
|
23516
|
+
},
|
|
23517
|
+
participant
|
|
23518
|
+
});
|
|
23519
|
+
|
|
23520
|
+
if ((_result = result) !== null && _result !== void 0 && _result.scaleItem) {
|
|
23521
|
+
seedValue = result.scaleItem.scaleValue;
|
|
23522
|
+
} else {
|
|
23523
|
+
var _result2;
|
|
23524
|
+
|
|
23525
|
+
result = participantScaleItem({
|
|
23526
|
+
scaleAttributes: {
|
|
23527
|
+
scaleType: SEEDING,
|
|
23528
|
+
scaleName: categoryName || ageCategoryCode,
|
|
23529
|
+
eventType: event === null || event === void 0 ? void 0 : event.eventType
|
|
23530
|
+
},
|
|
23531
|
+
participant
|
|
23532
|
+
});
|
|
23533
|
+
|
|
23534
|
+
if ((_result2 = result) !== null && _result2 !== void 0 && _result2.scaleItem) {
|
|
23535
|
+
seedValue = result.scaleItem.scaleValue;
|
|
23536
|
+
}
|
|
23537
|
+
}
|
|
23538
|
+
|
|
23539
|
+
if (seedValue) {
|
|
23540
|
+
var _eventsPublishStatuse, _publishedSeeding$dra, _publishedSeeding$dra2;
|
|
23541
|
+
|
|
23542
|
+
const publishedSeeding = (_eventsPublishStatuse = eventsPublishStatuses[participantDraw.eventId]) === null || _eventsPublishStatuse === void 0 ? void 0 : _eventsPublishStatuse.publishedSeeding;
|
|
23543
|
+
const seedingPublished = !usePublishState || (publishedSeeding === null || publishedSeeding === void 0 ? void 0 : publishedSeeding.published) && ((publishedSeeding === null || publishedSeeding === void 0 ? void 0 : (_publishedSeeding$dra = publishedSeeding.drawIds) === null || _publishedSeeding$dra === void 0 ? void 0 : _publishedSeeding$dra.length) === 0 || (publishedSeeding === null || publishedSeeding === void 0 ? void 0 : (_publishedSeeding$dra2 = publishedSeeding.drawIds) === null || _publishedSeeding$dra2 === void 0 ? void 0 : _publishedSeeding$dra2.includes(participantDraw.drawId)));
|
|
23544
|
+
|
|
23545
|
+
if (seedingPublished) {
|
|
23546
|
+
participantDraw.seedValue = seedValue;
|
|
23547
|
+
}
|
|
23548
|
+
}
|
|
23549
|
+
}
|
|
23550
|
+
}
|
|
23551
|
+
|
|
23552
|
+
if (withEvents && participantEvents) {
|
|
23553
|
+
participant.events = participantEvents;
|
|
23554
|
+
|
|
23555
|
+
for (const participantEvent of participantEvents) {
|
|
23556
|
+
const {
|
|
23557
|
+
categoryName,
|
|
23558
|
+
ageCategoryCode
|
|
23559
|
+
} = participantEvent.category || {};
|
|
23560
|
+
const scaleAttributes = {
|
|
23561
|
+
scaleType: SEEDING,
|
|
23562
|
+
scaleName: categoryName || ageCategoryCode,
|
|
23563
|
+
eventType: participantEvent.eventType
|
|
23564
|
+
};
|
|
23565
|
+
const result = participantScaleItem({
|
|
23566
|
+
scaleAttributes,
|
|
23567
|
+
participant
|
|
23568
|
+
});
|
|
23569
|
+
const {
|
|
23570
|
+
scaleItem
|
|
23571
|
+
} = result;
|
|
23572
|
+
|
|
23573
|
+
if (scaleItem) {
|
|
23574
|
+
var _eventsPublishStatuse2, _publishedSeeding$dra3, _publishedSeeding$dra4;
|
|
23575
|
+
|
|
23576
|
+
const seedValue = scaleItem.scaleValue;
|
|
23577
|
+
const publishedSeeding = (_eventsPublishStatuse2 = eventsPublishStatuses[participantEvent.eventId]) === null || _eventsPublishStatuse2 === void 0 ? void 0 : _eventsPublishStatuse2.publishedSeeding;
|
|
23578
|
+
const seedingPublished = !usePublishState || (publishedSeeding === null || publishedSeeding === void 0 ? void 0 : publishedSeeding.published) && ((publishedSeeding === null || publishedSeeding === void 0 ? void 0 : (_publishedSeeding$dra3 = publishedSeeding.drawIds) === null || _publishedSeeding$dra3 === void 0 ? void 0 : _publishedSeeding$dra3.length) === 0 || (publishedSeeding === null || publishedSeeding === void 0 ? void 0 : (_publishedSeeding$dra4 = publishedSeeding.drawIds) === null || _publishedSeeding$dra4 === void 0 ? void 0 : _publishedSeeding$dra4.includes(participantEvent.drawId)));
|
|
23579
|
+
|
|
23580
|
+
if (seedingPublished) {
|
|
23581
|
+
participantEvent.seedValue = seedValue;
|
|
23582
|
+
}
|
|
23583
|
+
}
|
|
23584
|
+
}
|
|
23585
|
+
}
|
|
23586
|
+
|
|
23338
23587
|
const participantOpponents = Object.values(opponents).flat();
|
|
23339
23588
|
|
|
23340
23589
|
if (withOpponents && participantOpponents !== null && participantOpponents !== void 0 && participantOpponents.length) {
|
|
@@ -23441,71 +23690,6 @@ function annotateParticipant({
|
|
|
23441
23690
|
};
|
|
23442
23691
|
}
|
|
23443
23692
|
|
|
23444
|
-
function getAccessorValue({
|
|
23445
|
-
element,
|
|
23446
|
-
accessor
|
|
23447
|
-
}) {
|
|
23448
|
-
if (typeof accessor !== 'string') return {
|
|
23449
|
-
values: []
|
|
23450
|
-
};
|
|
23451
|
-
const targetElement = makeDeepCopy(element);
|
|
23452
|
-
const attributes = accessor.split('.');
|
|
23453
|
-
let value,
|
|
23454
|
-
values = [];
|
|
23455
|
-
processKeys({
|
|
23456
|
-
targetElement,
|
|
23457
|
-
attributes
|
|
23458
|
-
});
|
|
23459
|
-
const result = {
|
|
23460
|
-
value
|
|
23461
|
-
};
|
|
23462
|
-
if (values.length) result.values = values;
|
|
23463
|
-
return result;
|
|
23464
|
-
|
|
23465
|
-
function processKeys({
|
|
23466
|
-
targetElement,
|
|
23467
|
-
attributes = [],
|
|
23468
|
-
significantCharacters
|
|
23469
|
-
}) {
|
|
23470
|
-
for (const [index, attribute] of attributes.entries()) {
|
|
23471
|
-
if (targetElement && targetElement[attribute]) {
|
|
23472
|
-
if (Array.isArray(targetElement[attribute])) {
|
|
23473
|
-
const values = targetElement[attribute];
|
|
23474
|
-
const remainingKeys = attributes.slice(index);
|
|
23475
|
-
values.forEach(nestedTarget => processKeys({
|
|
23476
|
-
targetElement: nestedTarget,
|
|
23477
|
-
attributes: remainingKeys
|
|
23478
|
-
}));
|
|
23479
|
-
} else {
|
|
23480
|
-
targetElement = targetElement[attribute];
|
|
23481
|
-
checkValue({
|
|
23482
|
-
targetElement,
|
|
23483
|
-
index
|
|
23484
|
-
});
|
|
23485
|
-
}
|
|
23486
|
-
}
|
|
23487
|
-
}
|
|
23488
|
-
|
|
23489
|
-
function checkValue({
|
|
23490
|
-
targetElement,
|
|
23491
|
-
index
|
|
23492
|
-
}) {
|
|
23493
|
-
if (targetElement && index === attributes.length - 1 && ['string', 'number'].includes(typeof targetElement)) {
|
|
23494
|
-
const extractedValue = significantCharacters ? targetElement.slice(0, significantCharacters) : targetElement;
|
|
23495
|
-
|
|
23496
|
-
if (value) {
|
|
23497
|
-
if (!values.includes(extractedValue)) {
|
|
23498
|
-
values.push(extractedValue);
|
|
23499
|
-
}
|
|
23500
|
-
} else {
|
|
23501
|
-
value = extractedValue;
|
|
23502
|
-
values.push(extractedValue);
|
|
23503
|
-
}
|
|
23504
|
-
}
|
|
23505
|
-
}
|
|
23506
|
-
}
|
|
23507
|
-
}
|
|
23508
|
-
|
|
23509
23693
|
function filterParticipants({
|
|
23510
23694
|
tournamentRecord,
|
|
23511
23695
|
participantFilters,
|
|
@@ -23652,6 +23836,7 @@ function getEventEntries({
|
|
|
23652
23836
|
* @param {boolean} scheduleAnalysis - analysis of conflicts
|
|
23653
23837
|
* @param {boolean} withGroupings - include teams and groups and pairs in which individual participants appear
|
|
23654
23838
|
* @param {boolean} withOpponents - include opponent participantIds
|
|
23839
|
+
* @param {boolean} usePublishState - when hydrating participants consider publish state (currently applies to seeding)
|
|
23655
23840
|
*
|
|
23656
23841
|
*/
|
|
23657
23842
|
|
|
@@ -23663,6 +23848,7 @@ function getTournamentParticipants({
|
|
|
23663
23848
|
withScheduleItems,
|
|
23664
23849
|
tournamentRecord,
|
|
23665
23850
|
scheduleAnalysis,
|
|
23851
|
+
usePublishState,
|
|
23666
23852
|
withStatistics,
|
|
23667
23853
|
withGroupings,
|
|
23668
23854
|
withOpponents,
|
|
@@ -23707,7 +23893,7 @@ function getTournamentParticipants({
|
|
|
23707
23893
|
participants: tournamentParticipants
|
|
23708
23894
|
});
|
|
23709
23895
|
const addContext = withSignInStatus || withScheduleItems || scheduleAnalysis || withStatistics || withGroupings || withOpponents || withMatchUps || withEvents || withDraws || withISO;
|
|
23710
|
-
let participantIdsWithConflicts;
|
|
23896
|
+
let participantIdsWithConflicts, eventsPublishStatuses;
|
|
23711
23897
|
|
|
23712
23898
|
if (addContext) {
|
|
23713
23899
|
const result = addParticipantContext({
|
|
@@ -23718,6 +23904,7 @@ function getTournamentParticipants({
|
|
|
23718
23904
|
withSignInStatus,
|
|
23719
23905
|
tournamentRecord,
|
|
23720
23906
|
scheduleAnalysis,
|
|
23907
|
+
usePublishState,
|
|
23721
23908
|
withStatistics,
|
|
23722
23909
|
withGroupings,
|
|
23723
23910
|
withOpponents,
|
|
@@ -23727,6 +23914,7 @@ function getTournamentParticipants({
|
|
|
23727
23914
|
withISO
|
|
23728
23915
|
});
|
|
23729
23916
|
participantIdsWithConflicts = result === null || result === void 0 ? void 0 : result.participantIdsWithConflicts;
|
|
23917
|
+
eventsPublishStatuses = result === null || result === void 0 ? void 0 : result.eventsPublishStatuses;
|
|
23730
23918
|
}
|
|
23731
23919
|
|
|
23732
23920
|
const participantAttributes = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_PARTICIPANT];
|
|
@@ -23739,8 +23927,9 @@ function getTournamentParticipants({
|
|
|
23739
23927
|
}
|
|
23740
23928
|
|
|
23741
23929
|
return {
|
|
23930
|
+
participantIdsWithConflicts,
|
|
23742
23931
|
tournamentParticipants,
|
|
23743
|
-
|
|
23932
|
+
eventsPublishStatuses
|
|
23744
23933
|
};
|
|
23745
23934
|
}
|
|
23746
23935
|
|
|
@@ -36324,11 +36513,10 @@ function removeParticipantIdsFromAllTeams({
|
|
|
36324
36513
|
}
|
|
36325
36514
|
|
|
36326
36515
|
function deleteParticipants({
|
|
36327
|
-
teamDrawIds = [],
|
|
36328
36516
|
tournamentRecord,
|
|
36329
36517
|
participantIds
|
|
36330
36518
|
}) {
|
|
36331
|
-
var _tournamentRecord$par;
|
|
36519
|
+
var _tournamentRecord$par, _tournamentRecord$eve;
|
|
36332
36520
|
|
|
36333
36521
|
if (!tournamentRecord) return {
|
|
36334
36522
|
error: MISSING_TOURNAMENT_RECORD
|
|
@@ -36338,6 +36526,15 @@ function deleteParticipants({
|
|
|
36338
36526
|
};
|
|
36339
36527
|
const participantsCount = ((_tournamentRecord$par = tournamentRecord.participants) === null || _tournamentRecord$par === void 0 ? void 0 : _tournamentRecord$par.length) || 0;
|
|
36340
36528
|
if (!participantsCount) return SUCCESS;
|
|
36529
|
+
const teamDrawIds = (_tournamentRecord$eve = tournamentRecord.events) === null || _tournamentRecord$eve === void 0 ? void 0 : _tournamentRecord$eve.filter(({
|
|
36530
|
+
eventType
|
|
36531
|
+
}) => eventType === TEAM$2).map(event => {
|
|
36532
|
+
var _event$drawDefinition;
|
|
36533
|
+
|
|
36534
|
+
return event === null || event === void 0 ? void 0 : (_event$drawDefinition = event.drawDefinitions) === null || _event$drawDefinition === void 0 ? void 0 : _event$drawDefinition.map(({
|
|
36535
|
+
drawId
|
|
36536
|
+
}) => drawId);
|
|
36537
|
+
}).flat(Infinity);
|
|
36341
36538
|
const {
|
|
36342
36539
|
tournamentParticipants
|
|
36343
36540
|
} = getTournamentParticipants({
|
|
@@ -36348,34 +36545,34 @@ function deleteParticipants({
|
|
|
36348
36545
|
tournamentRecord
|
|
36349
36546
|
});
|
|
36350
36547
|
|
|
36351
|
-
const
|
|
36548
|
+
const getPlacedPairParticipantIds = () => {
|
|
36352
36549
|
const {
|
|
36353
36550
|
matchUps
|
|
36354
36551
|
} = allTournamentMatchUps({
|
|
36355
|
-
tournamentRecord,
|
|
36356
36552
|
matchUpFilters: {
|
|
36357
36553
|
drawIds: teamDrawIds,
|
|
36358
36554
|
matchUpTypes: [DOUBLES$1]
|
|
36359
|
-
}
|
|
36555
|
+
},
|
|
36556
|
+
tournamentRecord
|
|
36360
36557
|
});
|
|
36361
|
-
const
|
|
36558
|
+
const placedPairParticipantIds = matchUps.map(({
|
|
36362
36559
|
sides
|
|
36363
36560
|
}) => sides.map(({
|
|
36364
36561
|
participantId
|
|
36365
36562
|
}) => participantId)).flat().filter(Boolean);
|
|
36366
|
-
return intersection(
|
|
36563
|
+
return intersection(placedPairParticipantIds, participantIds);
|
|
36367
36564
|
}; // for team draws it is necessary to check matchUps for pair participantIds "discovered" in collectionAssignments
|
|
36368
36565
|
|
|
36369
36566
|
|
|
36370
|
-
const
|
|
36567
|
+
const placedPairParticipantIds = (teamDrawIds === null || teamDrawIds === void 0 ? void 0 : teamDrawIds.length) && getPlacedPairParticipantIds();
|
|
36371
36568
|
const participantsInDraws = tournamentParticipants.filter(participant => {
|
|
36372
36569
|
var _participant$draws;
|
|
36373
36570
|
|
|
36374
36571
|
return (_participant$draws = participant.draws) === null || _participant$draws === void 0 ? void 0 : _participant$draws.filter(({
|
|
36375
36572
|
drawId
|
|
36376
|
-
}) => !teamDrawIds.length || !teamDrawIds.includes(drawId)).length;
|
|
36573
|
+
}) => !(teamDrawIds !== null && teamDrawIds !== void 0 && teamDrawIds.length) || !(teamDrawIds !== null && teamDrawIds !== void 0 && teamDrawIds.includes(drawId))).length;
|
|
36377
36574
|
});
|
|
36378
|
-
if (
|
|
36575
|
+
if (placedPairParticipantIds !== null && placedPairParticipantIds !== void 0 && placedPairParticipantIds.length || participantsInDraws.length) return {
|
|
36379
36576
|
error: PARTICIPANT_ASSIGNED_DRAW_POSITION
|
|
36380
36577
|
}; // If not active in draws, remove participantIds from all entries
|
|
36381
36578
|
|
|
@@ -37532,62 +37729,6 @@ function removeDelegatedOutcome$1({
|
|
|
37532
37729
|
});
|
|
37533
37730
|
}
|
|
37534
37731
|
|
|
37535
|
-
function participantScaleItem({
|
|
37536
|
-
requireTimeStamp,
|
|
37537
|
-
scaleAttributes,
|
|
37538
|
-
participant
|
|
37539
|
-
}) {
|
|
37540
|
-
if (!participant) return {
|
|
37541
|
-
error: MISSING_PARTICIPANT
|
|
37542
|
-
};
|
|
37543
|
-
if (typeof scaleAttributes !== 'object') return {
|
|
37544
|
-
error: INVALID_VALUES
|
|
37545
|
-
};
|
|
37546
|
-
if (!participant.timeItems) participant.timeItems = [];
|
|
37547
|
-
|
|
37548
|
-
if (participant && Array.isArray(participant.timeItems)) {
|
|
37549
|
-
const {
|
|
37550
|
-
accessor,
|
|
37551
|
-
scaleType,
|
|
37552
|
-
eventType,
|
|
37553
|
-
scaleName
|
|
37554
|
-
} = scaleAttributes;
|
|
37555
|
-
const filterType = [SCALE, scaleType, eventType, scaleName].join('.');
|
|
37556
|
-
const filteredTimeItems = participant.timeItems.filter(timeItem => (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemType) === filterType).filter(timeItem => !requireTimeStamp || (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemDate)).sort((a, b) => new Date(a.createdAt || undefined) - new Date(b.createdAt || undefined));
|
|
37557
|
-
const timeItem = filteredTimeItems.pop();
|
|
37558
|
-
|
|
37559
|
-
if (timeItem) {
|
|
37560
|
-
const [itemSubject, scaleType, eventType, scaleName] = timeItem.itemType.split('.');
|
|
37561
|
-
if (itemSubject !== SCALE) return {
|
|
37562
|
-
error: INVALID_SCALE_ITEM
|
|
37563
|
-
};
|
|
37564
|
-
const accessorValue = accessor && getAccessorValue({
|
|
37565
|
-
element: timeItem.itemValue,
|
|
37566
|
-
accessor
|
|
37567
|
-
});
|
|
37568
|
-
const scaleValue = accessor ? accessorValue.value : timeItem.itemValue;
|
|
37569
|
-
const scaleItem = {
|
|
37570
|
-
scaleDate: timeItem.itemDate,
|
|
37571
|
-
scaleName,
|
|
37572
|
-
scaleType,
|
|
37573
|
-
eventType,
|
|
37574
|
-
scaleValue
|
|
37575
|
-
};
|
|
37576
|
-
return {
|
|
37577
|
-
scaleItem
|
|
37578
|
-
};
|
|
37579
|
-
} else {
|
|
37580
|
-
return {
|
|
37581
|
-
error: SCALE_ITEM_NOT_FOUND
|
|
37582
|
-
};
|
|
37583
|
-
}
|
|
37584
|
-
}
|
|
37585
|
-
|
|
37586
|
-
return {
|
|
37587
|
-
error: MISSING_PARTICIPANT
|
|
37588
|
-
};
|
|
37589
|
-
}
|
|
37590
|
-
|
|
37591
37732
|
function generateCandidate({
|
|
37592
37733
|
maxIterations = 5000,
|
|
37593
37734
|
// cap the processing intensity of the candidate generator
|
|
@@ -42159,6 +42300,253 @@ const participantGovernor = {
|
|
|
42159
42300
|
getTournamentPersons
|
|
42160
42301
|
};
|
|
42161
42302
|
|
|
42303
|
+
function unPublishEventSeeding({
|
|
42304
|
+
tournamentRecord,
|
|
42305
|
+
status = PUBLIC,
|
|
42306
|
+
event
|
|
42307
|
+
}) {
|
|
42308
|
+
if (!tournamentRecord) return {
|
|
42309
|
+
error: MISSING_TOURNAMENT_RECORD
|
|
42310
|
+
};
|
|
42311
|
+
if (!event) return {
|
|
42312
|
+
error: MISSING_EVENT
|
|
42313
|
+
};
|
|
42314
|
+
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
42315
|
+
const {
|
|
42316
|
+
timeItem
|
|
42317
|
+
} = getEventTimeItem({
|
|
42318
|
+
itemType,
|
|
42319
|
+
event
|
|
42320
|
+
});
|
|
42321
|
+
const itemValue = (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) || {
|
|
42322
|
+
[status]: {}
|
|
42323
|
+
};
|
|
42324
|
+
if (itemValue[status]) delete itemValue[status].seeding;
|
|
42325
|
+
const updatedTimeItem = {
|
|
42326
|
+
itemValue,
|
|
42327
|
+
itemType
|
|
42328
|
+
};
|
|
42329
|
+
addEventTimeItem({
|
|
42330
|
+
event,
|
|
42331
|
+
timeItem: updatedTimeItem
|
|
42332
|
+
});
|
|
42333
|
+
addNotice({
|
|
42334
|
+
topic: UNPUBLISH_EVENT_SEEDING,
|
|
42335
|
+
payload: {
|
|
42336
|
+
eventId: event.eventId
|
|
42337
|
+
}
|
|
42338
|
+
});
|
|
42339
|
+
return { ...SUCCESS
|
|
42340
|
+
};
|
|
42341
|
+
}
|
|
42342
|
+
|
|
42343
|
+
function publishEventSeeding({
|
|
42344
|
+
tournamentRecord,
|
|
42345
|
+
status = PUBLIC,
|
|
42346
|
+
drawIds = [],
|
|
42347
|
+
event
|
|
42348
|
+
}) {
|
|
42349
|
+
if (!tournamentRecord) return {
|
|
42350
|
+
error: MISSING_TOURNAMENT_RECORD
|
|
42351
|
+
};
|
|
42352
|
+
if (!event) return {
|
|
42353
|
+
error: MISSING_EVENT
|
|
42354
|
+
};
|
|
42355
|
+
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
42356
|
+
const {
|
|
42357
|
+
timeItem
|
|
42358
|
+
} = getEventTimeItem({
|
|
42359
|
+
itemType,
|
|
42360
|
+
event
|
|
42361
|
+
});
|
|
42362
|
+
const itemValue = (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) || {
|
|
42363
|
+
[status]: {}
|
|
42364
|
+
};
|
|
42365
|
+
itemValue[status].seeding = {
|
|
42366
|
+
published: true,
|
|
42367
|
+
drawIds
|
|
42368
|
+
};
|
|
42369
|
+
const updatedTimeItem = {
|
|
42370
|
+
itemValue,
|
|
42371
|
+
itemType
|
|
42372
|
+
};
|
|
42373
|
+
addEventTimeItem({
|
|
42374
|
+
event,
|
|
42375
|
+
timeItem: updatedTimeItem
|
|
42376
|
+
});
|
|
42377
|
+
addNotice({
|
|
42378
|
+
topic: PUBLISH_EVENT_SEEDING,
|
|
42379
|
+
payload: {
|
|
42380
|
+
eventId: event.eventId,
|
|
42381
|
+
drawIds
|
|
42382
|
+
}
|
|
42383
|
+
});
|
|
42384
|
+
return { ...SUCCESS
|
|
42385
|
+
};
|
|
42386
|
+
}
|
|
42387
|
+
|
|
42388
|
+
function getAllEventData({
|
|
42389
|
+
tournamentRecord,
|
|
42390
|
+
policyDefinitions
|
|
42391
|
+
}) {
|
|
42392
|
+
if (!tournamentRecord) return {
|
|
42393
|
+
error: MISSING_TOURNAMENT_RECORD
|
|
42394
|
+
};
|
|
42395
|
+
const events = tournamentRecord.events || [];
|
|
42396
|
+
const tournamentParticipants = (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) || [];
|
|
42397
|
+
const {
|
|
42398
|
+
tournamentInfo
|
|
42399
|
+
} = getTournamentInfo({
|
|
42400
|
+
tournamentRecord
|
|
42401
|
+
});
|
|
42402
|
+
const {
|
|
42403
|
+
venues: venuesData
|
|
42404
|
+
} = getVenuesAndCourts$1({
|
|
42405
|
+
tournamentRecord
|
|
42406
|
+
});
|
|
42407
|
+
const eventsData = events.map(event => {
|
|
42408
|
+
const {
|
|
42409
|
+
eventId
|
|
42410
|
+
} = event;
|
|
42411
|
+
|
|
42412
|
+
const eventInfo = (({
|
|
42413
|
+
eventId,
|
|
42414
|
+
eventName,
|
|
42415
|
+
eventType,
|
|
42416
|
+
eventLevel,
|
|
42417
|
+
surfaceCategory,
|
|
42418
|
+
matchUpFormat,
|
|
42419
|
+
category,
|
|
42420
|
+
gender,
|
|
42421
|
+
startDate,
|
|
42422
|
+
endDate,
|
|
42423
|
+
ballType,
|
|
42424
|
+
discipline
|
|
42425
|
+
}) => ({
|
|
42426
|
+
eventId,
|
|
42427
|
+
eventName,
|
|
42428
|
+
eventType,
|
|
42429
|
+
eventLevel,
|
|
42430
|
+
surfaceCategory,
|
|
42431
|
+
matchUpFormat,
|
|
42432
|
+
category,
|
|
42433
|
+
gender,
|
|
42434
|
+
startDate,
|
|
42435
|
+
endDate,
|
|
42436
|
+
ballType,
|
|
42437
|
+
discipline
|
|
42438
|
+
}))(event);
|
|
42439
|
+
|
|
42440
|
+
const scheduleTiming = getScheduleTiming({
|
|
42441
|
+
tournamentRecord,
|
|
42442
|
+
event
|
|
42443
|
+
}).scheduleTiming;
|
|
42444
|
+
const drawsData = (event.drawDefinitions || []).map(drawDefinition => {
|
|
42445
|
+
const drawInfo = (({
|
|
42446
|
+
drawId,
|
|
42447
|
+
drawName,
|
|
42448
|
+
matchUpFormat,
|
|
42449
|
+
updatedAt
|
|
42450
|
+
}) => ({
|
|
42451
|
+
drawId,
|
|
42452
|
+
drawName,
|
|
42453
|
+
matchUpFormat,
|
|
42454
|
+
updatedAt
|
|
42455
|
+
}))(drawDefinition);
|
|
42456
|
+
|
|
42457
|
+
const {
|
|
42458
|
+
pendingMatchUps,
|
|
42459
|
+
completedMatchUps,
|
|
42460
|
+
upcomingMatchUps,
|
|
42461
|
+
abandonedMatchUps
|
|
42462
|
+
} = getDrawMatchUps({
|
|
42463
|
+
includeByeMatchUps: false,
|
|
42464
|
+
requireParticipants: true,
|
|
42465
|
+
tournamentParticipants,
|
|
42466
|
+
context: {
|
|
42467
|
+
eventId
|
|
42468
|
+
},
|
|
42469
|
+
policyDefinitions,
|
|
42470
|
+
tournamentRecord,
|
|
42471
|
+
inContext: true,
|
|
42472
|
+
drawDefinition,
|
|
42473
|
+
scheduleTiming,
|
|
42474
|
+
event
|
|
42475
|
+
});
|
|
42476
|
+
return {
|
|
42477
|
+
drawInfo,
|
|
42478
|
+
matchUps: {
|
|
42479
|
+
abandonedMatchUps,
|
|
42480
|
+
completedMatchUps,
|
|
42481
|
+
upcomingMatchUps,
|
|
42482
|
+
pendingMatchUps
|
|
42483
|
+
}
|
|
42484
|
+
};
|
|
42485
|
+
});
|
|
42486
|
+
const {
|
|
42487
|
+
timeItem
|
|
42488
|
+
} = getEventTimeItem({
|
|
42489
|
+
event,
|
|
42490
|
+
itemType: `${PUBLISH}.${STATUS$1}`
|
|
42491
|
+
});
|
|
42492
|
+
Object.assign(eventInfo, {
|
|
42493
|
+
publish: timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue,
|
|
42494
|
+
drawsData
|
|
42495
|
+
});
|
|
42496
|
+
return eventInfo;
|
|
42497
|
+
});
|
|
42498
|
+
const allEventData = {
|
|
42499
|
+
tournamentInfo,
|
|
42500
|
+
venuesData,
|
|
42501
|
+
eventsData
|
|
42502
|
+
};
|
|
42503
|
+
return {
|
|
42504
|
+
allEventData
|
|
42505
|
+
};
|
|
42506
|
+
}
|
|
42507
|
+
|
|
42508
|
+
function unPublishEvent({
|
|
42509
|
+
tournamentRecord,
|
|
42510
|
+
event,
|
|
42511
|
+
status = PUBLIC
|
|
42512
|
+
}) {
|
|
42513
|
+
if (!tournamentRecord) return {
|
|
42514
|
+
error: MISSING_TOURNAMENT_RECORD
|
|
42515
|
+
};
|
|
42516
|
+
if (!event) return {
|
|
42517
|
+
error: MISSING_EVENT
|
|
42518
|
+
};
|
|
42519
|
+
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
42520
|
+
const {
|
|
42521
|
+
timeItem
|
|
42522
|
+
} = getEventTimeItem({
|
|
42523
|
+
itemType,
|
|
42524
|
+
event
|
|
42525
|
+
});
|
|
42526
|
+
const itemValue = (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) || {
|
|
42527
|
+
[status]: {}
|
|
42528
|
+
};
|
|
42529
|
+
delete itemValue[status].drawIds;
|
|
42530
|
+
delete itemValue[status].structureIds;
|
|
42531
|
+
const updatedTimeItem = {
|
|
42532
|
+
itemValue,
|
|
42533
|
+
itemType
|
|
42534
|
+
};
|
|
42535
|
+
addEventTimeItem({
|
|
42536
|
+
event,
|
|
42537
|
+
timeItem: updatedTimeItem
|
|
42538
|
+
});
|
|
42539
|
+
addNotice({
|
|
42540
|
+
topic: UNPUBLISH_EVENT,
|
|
42541
|
+
payload: {
|
|
42542
|
+
eventId: event.eventId
|
|
42543
|
+
}
|
|
42544
|
+
});
|
|
42545
|
+
return Object.assign({
|
|
42546
|
+
eventId: event.eventId
|
|
42547
|
+
}, SUCCESS);
|
|
42548
|
+
}
|
|
42549
|
+
|
|
42162
42550
|
function getDrawData({
|
|
42163
42551
|
tournamentParticipants = [],
|
|
42164
42552
|
policyDefinitions,
|
|
@@ -42391,8 +42779,12 @@ function getEventData({
|
|
|
42391
42779
|
participantsProfile,
|
|
42392
42780
|
policyDefinitions,
|
|
42393
42781
|
tournamentRecord,
|
|
42782
|
+
usePublishState,
|
|
42783
|
+
status = PUBLIC,
|
|
42394
42784
|
event
|
|
42395
42785
|
}) {
|
|
42786
|
+
var _timeItem$itemValue;
|
|
42787
|
+
|
|
42396
42788
|
if (!tournamentRecord) return {
|
|
42397
42789
|
error: MISSING_TOURNAMENT_RECORD
|
|
42398
42790
|
};
|
|
@@ -42406,6 +42798,13 @@ function getEventData({
|
|
|
42406
42798
|
tournamentId,
|
|
42407
42799
|
endDate
|
|
42408
42800
|
} = tournamentRecord;
|
|
42801
|
+
const {
|
|
42802
|
+
timeItem
|
|
42803
|
+
} = getEventTimeItem({
|
|
42804
|
+
itemType: `${PUBLISH}.${STATUS$1}`,
|
|
42805
|
+
event
|
|
42806
|
+
});
|
|
42807
|
+
const publishStatus = timeItem === null || timeItem === void 0 ? void 0 : (_timeItem$itemValue = timeItem.itemValue) === null || _timeItem$itemValue === void 0 ? void 0 : _timeItem$itemValue[status];
|
|
42409
42808
|
const {
|
|
42410
42809
|
tournamentParticipants
|
|
42411
42810
|
} = getTournamentParticipants({
|
|
@@ -42418,7 +42817,11 @@ function getEventData({
|
|
|
42418
42817
|
tournamentRecord
|
|
42419
42818
|
});
|
|
42420
42819
|
const drawDefinitions = event.drawDefinitions || [];
|
|
42421
|
-
const drawsData = drawDefinitions.
|
|
42820
|
+
const drawsData = drawDefinitions.filter(drawDefinition => {
|
|
42821
|
+
var _publishStatus$drawId, _publishStatus$drawId2;
|
|
42822
|
+
|
|
42823
|
+
return !usePublishState || (publishStatus === null || publishStatus === void 0 ? void 0 : (_publishStatus$drawId = publishStatus.drawIds) === null || _publishStatus$drawId === void 0 ? void 0 : _publishStatus$drawId.length) === 0 || (publishStatus === null || publishStatus === void 0 ? void 0 : (_publishStatus$drawId2 = publishStatus.drawIds) === null || _publishStatus$drawId2 === void 0 ? void 0 : _publishStatus$drawId2.includes(drawDefinition.drawId));
|
|
42824
|
+
}).map(drawDefinition => (({
|
|
42422
42825
|
drawInfo,
|
|
42423
42826
|
structures
|
|
42424
42827
|
}) => ({ ...drawInfo,
|
|
@@ -42483,12 +42886,6 @@ function getEventData({
|
|
|
42483
42886
|
venuesData,
|
|
42484
42887
|
tournamentInfo
|
|
42485
42888
|
};
|
|
42486
|
-
const {
|
|
42487
|
-
timeItem
|
|
42488
|
-
} = getEventTimeItem({
|
|
42489
|
-
event,
|
|
42490
|
-
itemType: `${PUBLISH}.${STATUS$1}`
|
|
42491
|
-
});
|
|
42492
42889
|
eventData.eventInfo.publish = {
|
|
42493
42890
|
state: timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue,
|
|
42494
42891
|
createdAt: timeItem === null || timeItem === void 0 ? void 0 : timeItem.createdAt
|
|
@@ -42500,12 +42897,14 @@ function getEventData({
|
|
|
42500
42897
|
|
|
42501
42898
|
function publishEvent({
|
|
42502
42899
|
policyDefinitions,
|
|
42503
|
-
structureIds = [],
|
|
42504
42900
|
tournamentRecord,
|
|
42505
|
-
drawIdsToRemove,
|
|
42506
42901
|
status = PUBLIC,
|
|
42902
|
+
drawIdsToRemove,
|
|
42507
42903
|
drawIdsToAdd,
|
|
42508
42904
|
drawIds,
|
|
42905
|
+
structureIdsToRemove,
|
|
42906
|
+
structureIdsToAdd,
|
|
42907
|
+
structureIds,
|
|
42509
42908
|
event
|
|
42510
42909
|
}) {
|
|
42511
42910
|
var _event$drawDefinition, _eventData$eventInfo, _eventData$eventInfo$;
|
|
@@ -42520,43 +42919,58 @@ function publishEvent({
|
|
|
42520
42919
|
const eventDrawIds = ((_event$drawDefinition = event.drawDefinitions) === null || _event$drawDefinition === void 0 ? void 0 : _event$drawDefinition.map(({
|
|
42521
42920
|
drawId
|
|
42522
42921
|
}) => drawId)) || [];
|
|
42922
|
+
const {
|
|
42923
|
+
timeItem
|
|
42924
|
+
} = getEventTimeItem({
|
|
42925
|
+
itemType,
|
|
42926
|
+
event
|
|
42927
|
+
});
|
|
42523
42928
|
|
|
42524
42929
|
if (!drawIds && !drawIdsToAdd && !drawIdsToRemove) {
|
|
42930
|
+
// by default publish all drawIds in an event
|
|
42525
42931
|
drawIds = eventDrawIds;
|
|
42526
42932
|
} else if (!drawIds && (drawIdsToAdd !== null && drawIdsToAdd !== void 0 && drawIdsToAdd.length || drawIdsToRemove !== null && drawIdsToRemove !== void 0 && drawIdsToRemove.length)) {
|
|
42527
42933
|
var _timeItem$itemValue, _timeItem$itemValue$P;
|
|
42528
42934
|
|
|
42529
|
-
const {
|
|
42530
|
-
timeItem
|
|
42531
|
-
} = getEventTimeItem({
|
|
42532
|
-
itemType,
|
|
42533
|
-
event
|
|
42534
|
-
});
|
|
42535
42935
|
drawIds = (timeItem === null || timeItem === void 0 ? void 0 : (_timeItem$itemValue = timeItem.itemValue) === null || _timeItem$itemValue === void 0 ? void 0 : (_timeItem$itemValue$P = _timeItem$itemValue.PUBLIC) === null || _timeItem$itemValue$P === void 0 ? void 0 : _timeItem$itemValue$P.drawIds) || [];
|
|
42536
42936
|
}
|
|
42537
42937
|
|
|
42538
42938
|
drawIds = (drawIds || []).filter(drawId => !(drawIdsToRemove !== null && drawIdsToRemove !== void 0 && drawIdsToRemove.length) || !drawIdsToRemove.includes(drawId));
|
|
42539
42939
|
|
|
42540
42940
|
if (drawIdsToAdd !== null && drawIdsToAdd !== void 0 && drawIdsToAdd.length) {
|
|
42541
|
-
drawIds = unique(drawIds.concat(
|
|
42941
|
+
drawIds = unique(drawIds.concat( // ensure that only drawIds which are part of event are included
|
|
42942
|
+
...drawIdsToAdd.filter(drawId => eventDrawIds.includes(drawId))));
|
|
42542
42943
|
}
|
|
42543
42944
|
|
|
42544
|
-
|
|
42545
|
-
|
|
42945
|
+
if (!structureIds && (structureIdsToAdd !== null && structureIdsToAdd !== void 0 && structureIdsToAdd.length || structureIdsToRemove !== null && structureIdsToRemove !== void 0 && structureIdsToRemove.length)) {
|
|
42946
|
+
var _timeItem$itemValue2, _timeItem$itemValue2$;
|
|
42947
|
+
|
|
42948
|
+
structureIds = (timeItem === null || timeItem === void 0 ? void 0 : (_timeItem$itemValue2 = timeItem.itemValue) === null || _timeItem$itemValue2 === void 0 ? void 0 : (_timeItem$itemValue2$ = _timeItem$itemValue2.PUBLIC) === null || _timeItem$itemValue2$ === void 0 ? void 0 : _timeItem$itemValue2$.drawIds) || [];
|
|
42949
|
+
}
|
|
42950
|
+
|
|
42951
|
+
structureIds = (structureIds || []).filter(structureId => !(structureIdsToRemove !== null && structureIdsToRemove !== void 0 && structureIdsToRemove.length) || !structureIdsToRemove.includes(structureId));
|
|
42952
|
+
|
|
42953
|
+
if (structureIdsToAdd !== null && structureIdsToAdd !== void 0 && structureIdsToAdd.length) {
|
|
42954
|
+
structureIds = unique(structureIds.push(...structureIdsToAdd));
|
|
42955
|
+
}
|
|
42956
|
+
|
|
42957
|
+
const updatedTimeItem = {
|
|
42546
42958
|
itemValue: {
|
|
42547
42959
|
[status]: {
|
|
42548
42960
|
drawIds,
|
|
42549
42961
|
structureIds
|
|
42550
42962
|
}
|
|
42551
|
-
}
|
|
42963
|
+
},
|
|
42964
|
+
itemType
|
|
42552
42965
|
};
|
|
42553
42966
|
addEventTimeItem({
|
|
42554
42967
|
event,
|
|
42555
|
-
timeItem
|
|
42968
|
+
timeItem: updatedTimeItem
|
|
42556
42969
|
});
|
|
42557
42970
|
const {
|
|
42558
42971
|
eventData
|
|
42559
42972
|
} = getEventData({
|
|
42973
|
+
usePublishState: true,
|
|
42560
42974
|
policyDefinitions,
|
|
42561
42975
|
tournamentRecord,
|
|
42562
42976
|
event
|
|
@@ -42581,155 +42995,6 @@ function publishEvent({
|
|
|
42581
42995
|
};
|
|
42582
42996
|
}
|
|
42583
42997
|
|
|
42584
|
-
function unPublishEvent({
|
|
42585
|
-
tournamentRecord,
|
|
42586
|
-
event
|
|
42587
|
-
}) {
|
|
42588
|
-
if (!tournamentRecord) return {
|
|
42589
|
-
error: MISSING_TOURNAMENT_RECORD
|
|
42590
|
-
};
|
|
42591
|
-
if (!event) return {
|
|
42592
|
-
error: MISSING_EVENT
|
|
42593
|
-
};
|
|
42594
|
-
const timeItem = {
|
|
42595
|
-
itemType: `${PUBLISH}.${STATUS$1}`,
|
|
42596
|
-
itemValue: HIDDEN
|
|
42597
|
-
};
|
|
42598
|
-
addEventTimeItem({
|
|
42599
|
-
event,
|
|
42600
|
-
timeItem
|
|
42601
|
-
});
|
|
42602
|
-
addNotice({
|
|
42603
|
-
topic: UNPUBLISH_EVENT,
|
|
42604
|
-
payload: {
|
|
42605
|
-
eventId: event.eventId
|
|
42606
|
-
}
|
|
42607
|
-
});
|
|
42608
|
-
return Object.assign({
|
|
42609
|
-
eventId: event.eventId
|
|
42610
|
-
}, SUCCESS);
|
|
42611
|
-
}
|
|
42612
|
-
|
|
42613
|
-
function getAllEventData({
|
|
42614
|
-
tournamentRecord,
|
|
42615
|
-
policyDefinitions
|
|
42616
|
-
}) {
|
|
42617
|
-
if (!tournamentRecord) return {
|
|
42618
|
-
error: MISSING_TOURNAMENT_RECORD
|
|
42619
|
-
};
|
|
42620
|
-
const events = tournamentRecord.events || [];
|
|
42621
|
-
const tournamentParticipants = (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) || [];
|
|
42622
|
-
const {
|
|
42623
|
-
tournamentInfo
|
|
42624
|
-
} = getTournamentInfo({
|
|
42625
|
-
tournamentRecord
|
|
42626
|
-
});
|
|
42627
|
-
const {
|
|
42628
|
-
venues: venuesData
|
|
42629
|
-
} = getVenuesAndCourts$1({
|
|
42630
|
-
tournamentRecord
|
|
42631
|
-
});
|
|
42632
|
-
const eventsData = events.map(event => {
|
|
42633
|
-
const {
|
|
42634
|
-
eventId
|
|
42635
|
-
} = event;
|
|
42636
|
-
|
|
42637
|
-
const eventInfo = (({
|
|
42638
|
-
eventId,
|
|
42639
|
-
eventName,
|
|
42640
|
-
eventType,
|
|
42641
|
-
eventLevel,
|
|
42642
|
-
surfaceCategory,
|
|
42643
|
-
matchUpFormat,
|
|
42644
|
-
category,
|
|
42645
|
-
gender,
|
|
42646
|
-
startDate,
|
|
42647
|
-
endDate,
|
|
42648
|
-
ballType,
|
|
42649
|
-
discipline
|
|
42650
|
-
}) => ({
|
|
42651
|
-
eventId,
|
|
42652
|
-
eventName,
|
|
42653
|
-
eventType,
|
|
42654
|
-
eventLevel,
|
|
42655
|
-
surfaceCategory,
|
|
42656
|
-
matchUpFormat,
|
|
42657
|
-
category,
|
|
42658
|
-
gender,
|
|
42659
|
-
startDate,
|
|
42660
|
-
endDate,
|
|
42661
|
-
ballType,
|
|
42662
|
-
discipline
|
|
42663
|
-
}))(event);
|
|
42664
|
-
|
|
42665
|
-
const scheduleTiming = getScheduleTiming({
|
|
42666
|
-
tournamentRecord,
|
|
42667
|
-
event
|
|
42668
|
-
}).scheduleTiming;
|
|
42669
|
-
const drawsData = (event.drawDefinitions || []).map(drawDefinition => {
|
|
42670
|
-
const drawInfo = (({
|
|
42671
|
-
drawId,
|
|
42672
|
-
drawName,
|
|
42673
|
-
matchUpFormat,
|
|
42674
|
-
updatedAt
|
|
42675
|
-
}) => ({
|
|
42676
|
-
drawId,
|
|
42677
|
-
drawName,
|
|
42678
|
-
matchUpFormat,
|
|
42679
|
-
updatedAt
|
|
42680
|
-
}))(drawDefinition);
|
|
42681
|
-
|
|
42682
|
-
const {
|
|
42683
|
-
pendingMatchUps,
|
|
42684
|
-
completedMatchUps,
|
|
42685
|
-
upcomingMatchUps,
|
|
42686
|
-
abandonedMatchUps
|
|
42687
|
-
} = getDrawMatchUps({
|
|
42688
|
-
includeByeMatchUps: false,
|
|
42689
|
-
requireParticipants: true,
|
|
42690
|
-
tournamentParticipants,
|
|
42691
|
-
context: {
|
|
42692
|
-
eventId
|
|
42693
|
-
},
|
|
42694
|
-
policyDefinitions,
|
|
42695
|
-
tournamentRecord,
|
|
42696
|
-
inContext: true,
|
|
42697
|
-
drawDefinition,
|
|
42698
|
-
scheduleTiming,
|
|
42699
|
-
event
|
|
42700
|
-
});
|
|
42701
|
-
return {
|
|
42702
|
-
drawInfo,
|
|
42703
|
-
matchUps: {
|
|
42704
|
-
abandonedMatchUps,
|
|
42705
|
-
completedMatchUps,
|
|
42706
|
-
upcomingMatchUps,
|
|
42707
|
-
pendingMatchUps
|
|
42708
|
-
}
|
|
42709
|
-
};
|
|
42710
|
-
});
|
|
42711
|
-
const {
|
|
42712
|
-
timeItem
|
|
42713
|
-
} = getEventTimeItem({
|
|
42714
|
-
event,
|
|
42715
|
-
itemType: `${PUBLISH}.${STATUS$1}`
|
|
42716
|
-
});
|
|
42717
|
-
Object.assign(eventInfo, {
|
|
42718
|
-
publish: timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue,
|
|
42719
|
-
drawsData
|
|
42720
|
-
});
|
|
42721
|
-
return eventInfo;
|
|
42722
|
-
});
|
|
42723
|
-
const allEventData = {
|
|
42724
|
-
tournamentInfo,
|
|
42725
|
-
venuesData,
|
|
42726
|
-
eventsData
|
|
42727
|
-
};
|
|
42728
|
-
return {
|
|
42729
|
-
allEventData
|
|
42730
|
-
};
|
|
42731
|
-
}
|
|
42732
|
-
|
|
42733
42998
|
const publishingGovernor = {
|
|
42734
42999
|
getTournamentInfo,
|
|
42735
43000
|
getVenueData,
|
|
@@ -42737,8 +43002,10 @@ const publishingGovernor = {
|
|
|
42737
43002
|
getAllEventData,
|
|
42738
43003
|
getEventData,
|
|
42739
43004
|
getDrawData,
|
|
42740
|
-
|
|
42741
|
-
|
|
43005
|
+
unPublishEventSeeding,
|
|
43006
|
+
publishEventSeeding,
|
|
43007
|
+
unPublishEvent,
|
|
43008
|
+
publishEvent
|
|
42742
43009
|
};
|
|
42743
43010
|
|
|
42744
43011
|
function analyzeDraws({
|
|
@@ -43844,7 +44111,11 @@ const namedFormats = {
|
|
|
43844
44111
|
},
|
|
43845
44112
|
[LAVER_CUP]: LAVER_CUP_TIE_FORMAT,
|
|
43846
44113
|
[DOMINANT_DUO]: DOMINANT_DUO_TIE_FORMAT,
|
|
43847
|
-
[TEAM_DOUBLES_3_AGGREGATION]: TEAM_AGGREGATION_TIE_FORMAT
|
|
44114
|
+
[TEAM_DOUBLES_3_AGGREGATION]: TEAM_AGGREGATION_TIE_FORMAT,
|
|
44115
|
+
[USTA_INTERSECTIONAL]: USTA_INTERSECTIONAL_TIE_FORMAT,
|
|
44116
|
+
[USTA_LEVEL_1]: USTA_LEVEL_1_TIE_FORMAT,
|
|
44117
|
+
[USTA_SOUTHERN_LEVEL_5]: USTA_SOUTHERN_LEVEL_5_TIE_FORMAT,
|
|
44118
|
+
[USTA_ZONAL]: USTA_ZONAL_TIE_FORMAT
|
|
43848
44119
|
};
|
|
43849
44120
|
const tieFormatDefaults = ({
|
|
43850
44121
|
namedFormat,
|
|
@@ -44462,7 +44733,6 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
44462
44733
|
if (deleteParticipantId) {
|
|
44463
44734
|
const result = deleteParticipants({
|
|
44464
44735
|
participantIds: [deleteParticipantId],
|
|
44465
|
-
teamDrawIds: [drawDefinition.drawId],
|
|
44466
44736
|
tournamentRecord
|
|
44467
44737
|
});
|
|
44468
44738
|
if (result.error) console.log('cleanup', {
|
|
@@ -47437,8 +47707,8 @@ function bulkUpdatePublishedEventIds({
|
|
|
47437
47707
|
const {
|
|
47438
47708
|
timeItem
|
|
47439
47709
|
} = getEventTimeItem({
|
|
47440
|
-
|
|
47441
|
-
|
|
47710
|
+
itemType: `${PUBLISH}.${STATUS$1}`,
|
|
47711
|
+
event
|
|
47442
47712
|
});
|
|
47443
47713
|
const pubState = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue;
|
|
47444
47714
|
const {
|
|
@@ -47447,7 +47717,7 @@ function bulkUpdatePublishedEventIds({
|
|
|
47447
47717
|
const publishedDrawIds = eventIdsMap[eventId].filter(drawId => {
|
|
47448
47718
|
var _pubState$PUBLIC$draw;
|
|
47449
47719
|
|
|
47450
|
-
return pubState && pubState[PUBLIC] && ((_pubState$PUBLIC$draw = pubState[PUBLIC].drawIds) === null || _pubState$PUBLIC$draw === void 0 ? void 0 : _pubState$PUBLIC$draw.includes(drawId))
|
|
47720
|
+
return pubState && pubState[PUBLIC] && ((_pubState$PUBLIC$draw = pubState[PUBLIC].drawIds) === null || _pubState$PUBLIC$draw === void 0 ? void 0 : _pubState$PUBLIC$draw.includes(drawId));
|
|
47451
47721
|
});
|
|
47452
47722
|
return publishedDrawIds.length;
|
|
47453
47723
|
}).map(event => event.eventId);
|
|
@@ -51675,25 +51945,132 @@ function completeDrawMatchUps({
|
|
|
51675
51945
|
matchUpStatusProfile,
|
|
51676
51946
|
completeAllMatchUps,
|
|
51677
51947
|
randomWinningSide,
|
|
51948
|
+
tournamentRecord,
|
|
51678
51949
|
drawDefinition,
|
|
51679
51950
|
completionGoal,
|
|
51680
51951
|
matchUpFormat,
|
|
51681
51952
|
event
|
|
51682
51953
|
}) {
|
|
51683
51954
|
const sortedStructures = drawDefinition.structures.slice().sort(structureSort);
|
|
51684
|
-
let completedCount = 0;
|
|
51955
|
+
let completedCount = 0;
|
|
51956
|
+
let {
|
|
51957
|
+
matchUps: firstRoundDualMatchUps,
|
|
51958
|
+
matchUpsMap
|
|
51959
|
+
} = getAllDrawMatchUps({
|
|
51960
|
+
contextFilters: {
|
|
51961
|
+
stages: [MAIN]
|
|
51962
|
+
},
|
|
51963
|
+
matchUpFilters: {
|
|
51964
|
+
matchUpTypes: [TEAM$3],
|
|
51965
|
+
roundNumbers: [1]
|
|
51966
|
+
},
|
|
51967
|
+
inContext: true,
|
|
51968
|
+
drawDefinition
|
|
51969
|
+
});
|
|
51970
|
+
|
|
51971
|
+
if (firstRoundDualMatchUps.length) {
|
|
51972
|
+
var _firstRoundDualMatchU;
|
|
51973
|
+
|
|
51974
|
+
const structureId = (_firstRoundDualMatchU = firstRoundDualMatchUps[0]) === null || _firstRoundDualMatchU === void 0 ? void 0 : _firstRoundDualMatchU.structureId;
|
|
51975
|
+
const {
|
|
51976
|
+
positionAssignments
|
|
51977
|
+
} = getPositionAssignments$1({
|
|
51978
|
+
drawDefinition,
|
|
51979
|
+
structureId
|
|
51980
|
+
});
|
|
51981
|
+
|
|
51982
|
+
if (positionAssignments !== null && positionAssignments !== void 0 && positionAssignments.length) {
|
|
51983
|
+
let {
|
|
51984
|
+
tournamentParticipants: teamParticipants
|
|
51985
|
+
} = getTournamentParticipants({
|
|
51986
|
+
participantFilters: {
|
|
51987
|
+
participantTypes: [TEAM$3]
|
|
51988
|
+
},
|
|
51989
|
+
tournamentRecord
|
|
51990
|
+
});
|
|
51991
|
+
|
|
51992
|
+
const assignParticipants = dualMatchUp => {
|
|
51993
|
+
const singlesMatchUps = dualMatchUp.tieMatchUps.filter(({
|
|
51994
|
+
matchUpType
|
|
51995
|
+
}) => matchUpType === SINGLES$1);
|
|
51996
|
+
const doublesMatchUps = dualMatchUp.tieMatchUps.filter(({
|
|
51997
|
+
matchUpType
|
|
51998
|
+
}) => matchUpType === DOUBLES$1);
|
|
51999
|
+
singlesMatchUps.forEach((singlesMatchUp, i) => {
|
|
52000
|
+
const tieMatchUpId = singlesMatchUp.matchUpId;
|
|
52001
|
+
singlesMatchUp.sides.forEach(side => {
|
|
52002
|
+
const {
|
|
52003
|
+
drawPosition
|
|
52004
|
+
} = side;
|
|
52005
|
+
const teamParticipant = teamParticipants.find(teamParticipant => {
|
|
52006
|
+
const {
|
|
52007
|
+
participantId
|
|
52008
|
+
} = teamParticipant;
|
|
52009
|
+
const assignment = positionAssignments.find(assignment => assignment.participantId === participantId);
|
|
52010
|
+
return assignment.drawPosition === drawPosition;
|
|
52011
|
+
});
|
|
52012
|
+
|
|
52013
|
+
if (teamParticipant) {
|
|
52014
|
+
const individualParticipantId = teamParticipant.individualParticipantIds[i];
|
|
52015
|
+
const result = assignTieMatchUpParticipantId({
|
|
52016
|
+
participantId: individualParticipantId,
|
|
52017
|
+
tournamentRecord,
|
|
52018
|
+
drawDefinition,
|
|
52019
|
+
tieMatchUpId,
|
|
52020
|
+
event
|
|
52021
|
+
});
|
|
52022
|
+
if (!result.success) console.log(result);
|
|
52023
|
+
}
|
|
52024
|
+
});
|
|
52025
|
+
});
|
|
52026
|
+
doublesMatchUps.forEach((doublesMatchUp, i) => {
|
|
52027
|
+
const tieMatchUpId = doublesMatchUp.matchUpId;
|
|
52028
|
+
doublesMatchUp.sides.forEach(side => {
|
|
52029
|
+
const {
|
|
52030
|
+
drawPosition
|
|
52031
|
+
} = side;
|
|
52032
|
+
const teamParticipant = teamParticipants.find(teamParticipant => {
|
|
52033
|
+
const {
|
|
52034
|
+
participantId
|
|
52035
|
+
} = teamParticipant;
|
|
52036
|
+
const assignment = positionAssignments.find(assignment => assignment.participantId === participantId);
|
|
52037
|
+
return assignment.drawPosition === drawPosition;
|
|
52038
|
+
});
|
|
52039
|
+
|
|
52040
|
+
if (teamParticipant) {
|
|
52041
|
+
const individualParticipantIds = teamParticipant.individualParticipantIds.slice(i * 2, i * 2 + 2);
|
|
52042
|
+
individualParticipantIds.forEach(individualParticipantId => {
|
|
52043
|
+
const result = assignTieMatchUpParticipantId({
|
|
52044
|
+
participantId: individualParticipantId,
|
|
52045
|
+
tournamentRecord,
|
|
52046
|
+
drawDefinition,
|
|
52047
|
+
tieMatchUpId,
|
|
52048
|
+
event
|
|
52049
|
+
});
|
|
52050
|
+
if (!result.success) console.log(result);
|
|
52051
|
+
});
|
|
52052
|
+
}
|
|
52053
|
+
});
|
|
52054
|
+
});
|
|
52055
|
+
};
|
|
52056
|
+
|
|
52057
|
+
firstRoundDualMatchUps.forEach(assignParticipants);
|
|
52058
|
+
}
|
|
52059
|
+
} // to support legacy tests it is possible to use completeAllMatchUps
|
|
51685
52060
|
// to pass a score string that will be applied to all matchUps
|
|
51686
52061
|
|
|
52062
|
+
|
|
51687
52063
|
const scoreString = typeof completeAllMatchUps === 'string' && completeAllMatchUps;
|
|
51688
52064
|
const matchUpStatus = scoreString && COMPLETED;
|
|
51689
52065
|
|
|
51690
52066
|
for (const structure of sortedStructures) {
|
|
51691
|
-
const matchUpsMap = getMatchUpsMap({
|
|
51692
|
-
drawDefinition
|
|
51693
|
-
});
|
|
51694
52067
|
const {
|
|
51695
52068
|
matchUps
|
|
51696
52069
|
} = getAllStructureMatchUps({
|
|
52070
|
+
matchUpFilters: {
|
|
52071
|
+
matchUpTypes: [DOUBLES$1, SINGLES$1]
|
|
52072
|
+
},
|
|
52073
|
+
tournamentRecord,
|
|
51697
52074
|
inContext: true,
|
|
51698
52075
|
drawDefinition,
|
|
51699
52076
|
matchUpsMap,
|
|
@@ -51709,6 +52086,10 @@ function completeDrawMatchUps({
|
|
|
51709
52086
|
const {
|
|
51710
52087
|
matchUps
|
|
51711
52088
|
} = getAllStructureMatchUps({
|
|
52089
|
+
matchUpFilters: {
|
|
52090
|
+
matchUpTypes: [DOUBLES$1, SINGLES$1]
|
|
52091
|
+
},
|
|
52092
|
+
tournamentRecord,
|
|
51712
52093
|
inContext: true,
|
|
51713
52094
|
drawDefinition,
|
|
51714
52095
|
matchUpsMap,
|
|
@@ -51938,12 +52319,14 @@ function generateFlightDrawDefinitions({
|
|
|
51938
52319
|
if (!manual && (completeAllMatchUps || completionGoal)) {
|
|
51939
52320
|
const matchUpFormat = drawProfile === null || drawProfile === void 0 ? void 0 : drawProfile.matchUpFormat;
|
|
51940
52321
|
const result = completeDrawMatchUps({
|
|
51941
|
-
matchUpStatusProfile,
|
|
51942
52322
|
completeAllMatchUps: !completionGoal && completeAllMatchUps,
|
|
52323
|
+
matchUpStatusProfile,
|
|
51943
52324
|
randomWinningSide,
|
|
52325
|
+
tournamentRecord,
|
|
51944
52326
|
completionGoal,
|
|
51945
52327
|
drawDefinition,
|
|
51946
|
-
matchUpFormat
|
|
52328
|
+
matchUpFormat,
|
|
52329
|
+
event
|
|
51947
52330
|
});
|
|
51948
52331
|
if (result.error) return result;
|
|
51949
52332
|
const completedCount = result.completedCount;
|
|
@@ -51963,8 +52346,10 @@ function generateFlightDrawDefinitions({
|
|
|
51963
52346
|
completionGoal: completionGoal ? playoffCompletionGoal : undefined,
|
|
51964
52347
|
matchUpStatusProfile,
|
|
51965
52348
|
randomWinningSide,
|
|
52349
|
+
tournamentRecord,
|
|
51966
52350
|
drawDefinition,
|
|
51967
|
-
matchUpFormat
|
|
52351
|
+
matchUpFormat,
|
|
52352
|
+
event
|
|
51968
52353
|
});
|
|
51969
52354
|
if (result.error) return result;
|
|
51970
52355
|
}
|
|
@@ -53015,6 +53400,7 @@ function generateEventWithDraw({
|
|
|
53015
53400
|
const individualParticipantIds = allIndividualParticipantIds.slice(teamIndex * teamSize, (teamIndex + 1) * teamSize);
|
|
53016
53401
|
return {
|
|
53017
53402
|
participantName: `Team ${teamIndex + 1}`,
|
|
53403
|
+
participantOtherName: `TM${teamIndex + 1}`,
|
|
53018
53404
|
participantRole: COMPETITOR,
|
|
53019
53405
|
participantType: TEAM$1,
|
|
53020
53406
|
participantId: UUID(),
|
|
@@ -53169,6 +53555,45 @@ function generateEventWithDraw({
|
|
|
53169
53555
|
const manual = drawProfile.automated === false;
|
|
53170
53556
|
|
|
53171
53557
|
if (!manual) {
|
|
53558
|
+
if (completeAllMatchUps || completionGoal) {
|
|
53559
|
+
const result = completeDrawMatchUps({
|
|
53560
|
+
matchUpStatusProfile,
|
|
53561
|
+
completeAllMatchUps,
|
|
53562
|
+
randomWinningSide,
|
|
53563
|
+
tournamentRecord,
|
|
53564
|
+
completionGoal,
|
|
53565
|
+
drawDefinition,
|
|
53566
|
+
matchUpFormat,
|
|
53567
|
+
event
|
|
53568
|
+
});
|
|
53569
|
+
if (result.error) return result;
|
|
53570
|
+
const completedCount = result.completedCount;
|
|
53571
|
+
|
|
53572
|
+
if (drawType === ROUND_ROBIN_WITH_PLAYOFF) {
|
|
53573
|
+
const mainStructure = drawDefinition.structures.find(structure => structure.stage === MAIN);
|
|
53574
|
+
let result = automatedPlayoffPositioning({
|
|
53575
|
+
structureId: mainStructure.structureId,
|
|
53576
|
+
tournamentRecord,
|
|
53577
|
+
drawDefinition,
|
|
53578
|
+
event
|
|
53579
|
+
}); // ignore when positioning cannot occur because of incomplete source structure
|
|
53580
|
+
|
|
53581
|
+
const playoffCompletionGoal = completionGoal ? completionGoal - completedCount : undefined;
|
|
53582
|
+
result = completeDrawMatchUps({
|
|
53583
|
+
completionGoal: completionGoal ? playoffCompletionGoal : undefined,
|
|
53584
|
+
matchUpStatusProfile,
|
|
53585
|
+
completeAllMatchUps,
|
|
53586
|
+
randomWinningSide,
|
|
53587
|
+
tournamentRecord,
|
|
53588
|
+
drawDefinition,
|
|
53589
|
+
matchUpFormat,
|
|
53590
|
+
event
|
|
53591
|
+
});
|
|
53592
|
+
if (result.error) return result;
|
|
53593
|
+
} // TODO: check if RRWPO & automate & complete
|
|
53594
|
+
|
|
53595
|
+
}
|
|
53596
|
+
|
|
53172
53597
|
if (drawProfile.outcomes) {
|
|
53173
53598
|
const {
|
|
53174
53599
|
matchUps
|
|
@@ -53230,41 +53655,6 @@ function generateEventWithDraw({
|
|
|
53230
53655
|
if (result !== null && result !== void 0 && result.error) return result;
|
|
53231
53656
|
}
|
|
53232
53657
|
}
|
|
53233
|
-
|
|
53234
|
-
if (completeAllMatchUps || completionGoal) {
|
|
53235
|
-
const result = completeDrawMatchUps({
|
|
53236
|
-
matchUpStatusProfile,
|
|
53237
|
-
completeAllMatchUps,
|
|
53238
|
-
randomWinningSide,
|
|
53239
|
-
completionGoal,
|
|
53240
|
-
drawDefinition,
|
|
53241
|
-
matchUpFormat
|
|
53242
|
-
});
|
|
53243
|
-
if (result.error) return result;
|
|
53244
|
-
const completedCount = result.completedCount;
|
|
53245
|
-
|
|
53246
|
-
if (drawType === ROUND_ROBIN_WITH_PLAYOFF) {
|
|
53247
|
-
const mainStructure = drawDefinition.structures.find(structure => structure.stage === MAIN);
|
|
53248
|
-
let result = automatedPlayoffPositioning({
|
|
53249
|
-
structureId: mainStructure.structureId,
|
|
53250
|
-
tournamentRecord,
|
|
53251
|
-
drawDefinition,
|
|
53252
|
-
event
|
|
53253
|
-
}); // ignore when positioning cannot occur because of incomplete source structure
|
|
53254
|
-
|
|
53255
|
-
const playoffCompletionGoal = completionGoal ? completionGoal - completedCount : undefined;
|
|
53256
|
-
result = completeDrawMatchUps({
|
|
53257
|
-
completionGoal: completionGoal ? playoffCompletionGoal : undefined,
|
|
53258
|
-
matchUpStatusProfile,
|
|
53259
|
-
completeAllMatchUps,
|
|
53260
|
-
randomWinningSide,
|
|
53261
|
-
drawDefinition,
|
|
53262
|
-
matchUpFormat
|
|
53263
|
-
});
|
|
53264
|
-
if (result.error) return result;
|
|
53265
|
-
} // TODO: check if RRWPO & automate & complete
|
|
53266
|
-
|
|
53267
|
-
}
|
|
53268
53658
|
}
|
|
53269
53659
|
|
|
53270
53660
|
if (publish) {
|