tods-competition-factory 1.8.46 → 1.9.1
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 +155 -81
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +5 -2
- package/dist/forge/query.mjs +327 -163
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +97 -61
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs +7 -4
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +630 -340
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +842 -475
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +6 -6
package/dist/forge/query.mjs
CHANGED
|
@@ -743,13 +743,18 @@ function getAccessorValue({ element, accessor }) {
|
|
|
743
743
|
}
|
|
744
744
|
|
|
745
745
|
function isObject(obj) {
|
|
746
|
-
return typeof obj === "object";
|
|
746
|
+
return obj !== null && typeof obj === "object";
|
|
747
747
|
}
|
|
748
748
|
const extractAttributes = (accessor) => (element) => !accessor || typeof element !== "object" ? void 0 : Array.isArray(accessor) && accessor.map((a) => ({
|
|
749
749
|
[a]: getAccessorValue({ element, accessor: a })?.value
|
|
750
750
|
})) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
|
|
751
751
|
[key]: getAccessorValue({ element, accessor: key })?.value
|
|
752
752
|
})) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
|
|
753
|
+
function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
|
|
754
|
+
return Object.keys(obj).filter(
|
|
755
|
+
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
756
|
+
);
|
|
757
|
+
}
|
|
753
758
|
function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
754
759
|
if (typeof obj !== "object" || obj === null)
|
|
755
760
|
return obj;
|
|
@@ -759,9 +764,7 @@ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
|
759
764
|
const ignoreValues = ["", void 0, null];
|
|
760
765
|
if (ignoreFalse)
|
|
761
766
|
ignoreValues.push(false);
|
|
762
|
-
const definedKeys =
|
|
763
|
-
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
764
|
-
);
|
|
767
|
+
const definedKeys = getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays);
|
|
765
768
|
return Object.assign(
|
|
766
769
|
{},
|
|
767
770
|
...definedKeys.map((key) => {
|
|
@@ -1694,6 +1697,99 @@ function getScheduleTiming({
|
|
|
1694
1697
|
return { scheduleTiming };
|
|
1695
1698
|
}
|
|
1696
1699
|
|
|
1700
|
+
function getTimeItem({
|
|
1701
|
+
returnPreviousValues,
|
|
1702
|
+
itemSubTypes,
|
|
1703
|
+
itemType,
|
|
1704
|
+
element
|
|
1705
|
+
}) {
|
|
1706
|
+
if (!element)
|
|
1707
|
+
return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
|
|
1708
|
+
if (itemSubTypes && !Array.isArray(itemSubTypes))
|
|
1709
|
+
return { error: INVALID_VALUES, context: { itemSubTypes } };
|
|
1710
|
+
if (!Array.isArray(element.timeItems))
|
|
1711
|
+
return { error: MISSING_TIME_ITEMS };
|
|
1712
|
+
const filteredSorted = element.timeItems.filter((timeItem2) => timeItem2?.itemType === itemType).filter(
|
|
1713
|
+
(timeItem2) => !itemSubTypes?.length || itemSubTypes.some(
|
|
1714
|
+
(subType) => timeItem2?.itemSubTypes?.includes(subType)
|
|
1715
|
+
)
|
|
1716
|
+
).sort((a, b) => {
|
|
1717
|
+
const aDate = new Date(a.createdAt || void 0).getTime();
|
|
1718
|
+
const bDate = new Date(b.createdAt || void 0).getTime();
|
|
1719
|
+
return aDate - bDate;
|
|
1720
|
+
});
|
|
1721
|
+
const timeItem = filteredSorted.pop();
|
|
1722
|
+
if (timeItem) {
|
|
1723
|
+
const result = { timeItem, ...SUCCESS };
|
|
1724
|
+
if (returnPreviousValues)
|
|
1725
|
+
Object.assign(result, { previousItems: filteredSorted });
|
|
1726
|
+
return result;
|
|
1727
|
+
} else {
|
|
1728
|
+
return { info: NOT_FOUND };
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
function getEventTimeItem({
|
|
1732
|
+
returnPreviousValues,
|
|
1733
|
+
itemSubTypes,
|
|
1734
|
+
itemType,
|
|
1735
|
+
event
|
|
1736
|
+
}) {
|
|
1737
|
+
if (!event)
|
|
1738
|
+
return { error: MISSING_EVENT };
|
|
1739
|
+
if (!event.timeItems)
|
|
1740
|
+
return { info: NOT_FOUND };
|
|
1741
|
+
const { timeItem, previousItems, info } = getTimeItem({
|
|
1742
|
+
returnPreviousValues,
|
|
1743
|
+
element: event,
|
|
1744
|
+
itemSubTypes,
|
|
1745
|
+
itemType
|
|
1746
|
+
});
|
|
1747
|
+
return timeItem && { timeItem, previousItems } || { info };
|
|
1748
|
+
}
|
|
1749
|
+
function getTournamentTimeItem({
|
|
1750
|
+
returnPreviousValues,
|
|
1751
|
+
tournamentRecord,
|
|
1752
|
+
itemSubTypes,
|
|
1753
|
+
itemType
|
|
1754
|
+
}) {
|
|
1755
|
+
if (!tournamentRecord)
|
|
1756
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
1757
|
+
if (!tournamentRecord.timeItems)
|
|
1758
|
+
return { info: NOT_FOUND };
|
|
1759
|
+
const { timeItem, previousItems, info } = getTimeItem({
|
|
1760
|
+
element: tournamentRecord,
|
|
1761
|
+
returnPreviousValues,
|
|
1762
|
+
itemSubTypes,
|
|
1763
|
+
itemType
|
|
1764
|
+
});
|
|
1765
|
+
return timeItem && { timeItem, previousItems } || { info };
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
const CHECK_IN = "CHECK_IN";
|
|
1769
|
+
const CHECK_OUT = "CHECK_OUT";
|
|
1770
|
+
const ASSIGN_VENUE = "SCHEDULE.ASSIGNMENT.VENUE";
|
|
1771
|
+
const ALLOCATE_COURTS = "SCHEDULE.ALLOCATION.COURTS";
|
|
1772
|
+
const ASSIGN_COURT = "SCHEDULE.ASSIGNMENT.COURT";
|
|
1773
|
+
const COURT_ORDER = "SCHEDULE.COURT.ORDER";
|
|
1774
|
+
const SCHEDULED_DATE = "SCHEDULE.DATE";
|
|
1775
|
+
const SCHEDULED_TIME = "SCHEDULE.TIME.SCHEDULED";
|
|
1776
|
+
const START_TIME = "SCHEDULE.TIME.START";
|
|
1777
|
+
const STOP_TIME = "SCHEDULE.TIME.STOP";
|
|
1778
|
+
const RESUME_TIME = "SCHEDULE.TIME.RESUME";
|
|
1779
|
+
const END_TIME = "SCHEDULE.TIME.END";
|
|
1780
|
+
const TIME_MODIFIERS = "SCHEDULE.TIME.MODIFIERS";
|
|
1781
|
+
const PUBLISH = "PUBLISH";
|
|
1782
|
+
const PUBLIC = "PUBLIC";
|
|
1783
|
+
const STATUS$1 = "STATUS";
|
|
1784
|
+
|
|
1785
|
+
function getEventPublishStatus({ event, status = PUBLIC }) {
|
|
1786
|
+
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
1787
|
+
return getEventTimeItem({
|
|
1788
|
+
itemType,
|
|
1789
|
+
event
|
|
1790
|
+
})?.timeItem?.itemValue?.[status];
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1697
1793
|
const SIGN_IN_STATUS = "SIGN_IN_STATUS";
|
|
1698
1794
|
const INDIVIDUAL = ParticipantTypeEnum.Individual;
|
|
1699
1795
|
const GROUP = ParticipantTypeEnum.Group;
|
|
@@ -3560,74 +3656,6 @@ function addIndividualParticipants({ participantMap, template }) {
|
|
|
3560
3656
|
}
|
|
3561
3657
|
}
|
|
3562
3658
|
|
|
3563
|
-
function getTimeItem({
|
|
3564
|
-
returnPreviousValues,
|
|
3565
|
-
itemSubTypes,
|
|
3566
|
-
itemType,
|
|
3567
|
-
element
|
|
3568
|
-
}) {
|
|
3569
|
-
if (!element)
|
|
3570
|
-
return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
|
|
3571
|
-
if (itemSubTypes && !Array.isArray(itemSubTypes))
|
|
3572
|
-
return { error: INVALID_VALUES, context: { itemSubTypes } };
|
|
3573
|
-
if (!Array.isArray(element.timeItems))
|
|
3574
|
-
return { error: MISSING_TIME_ITEMS };
|
|
3575
|
-
const filteredSorted = element.timeItems.filter((timeItem2) => timeItem2?.itemType === itemType).filter(
|
|
3576
|
-
(timeItem2) => !itemSubTypes?.length || itemSubTypes.some(
|
|
3577
|
-
(subType) => timeItem2?.itemSubTypes?.includes(subType)
|
|
3578
|
-
)
|
|
3579
|
-
).sort((a, b) => {
|
|
3580
|
-
const aDate = new Date(a.createdAt || void 0).getTime();
|
|
3581
|
-
const bDate = new Date(b.createdAt || void 0).getTime();
|
|
3582
|
-
return aDate - bDate;
|
|
3583
|
-
});
|
|
3584
|
-
const timeItem = filteredSorted.pop();
|
|
3585
|
-
if (timeItem) {
|
|
3586
|
-
const result = { timeItem, ...SUCCESS };
|
|
3587
|
-
if (returnPreviousValues)
|
|
3588
|
-
Object.assign(result, { previousItems: filteredSorted });
|
|
3589
|
-
return result;
|
|
3590
|
-
} else {
|
|
3591
|
-
return { info: NOT_FOUND };
|
|
3592
|
-
}
|
|
3593
|
-
}
|
|
3594
|
-
function getEventTimeItem({
|
|
3595
|
-
returnPreviousValues,
|
|
3596
|
-
itemSubTypes,
|
|
3597
|
-
itemType,
|
|
3598
|
-
event
|
|
3599
|
-
}) {
|
|
3600
|
-
if (!event)
|
|
3601
|
-
return { error: MISSING_EVENT };
|
|
3602
|
-
if (!event.timeItems)
|
|
3603
|
-
return { info: NOT_FOUND };
|
|
3604
|
-
const { timeItem, previousItems, info } = getTimeItem({
|
|
3605
|
-
returnPreviousValues,
|
|
3606
|
-
element: event,
|
|
3607
|
-
itemSubTypes,
|
|
3608
|
-
itemType
|
|
3609
|
-
});
|
|
3610
|
-
return timeItem && { timeItem, previousItems } || { info };
|
|
3611
|
-
}
|
|
3612
|
-
function getTournamentTimeItem({
|
|
3613
|
-
returnPreviousValues,
|
|
3614
|
-
tournamentRecord,
|
|
3615
|
-
itemSubTypes,
|
|
3616
|
-
itemType
|
|
3617
|
-
}) {
|
|
3618
|
-
if (!tournamentRecord)
|
|
3619
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
3620
|
-
if (!tournamentRecord.timeItems)
|
|
3621
|
-
return { info: NOT_FOUND };
|
|
3622
|
-
const { timeItem, previousItems, info } = getTimeItem({
|
|
3623
|
-
element: tournamentRecord,
|
|
3624
|
-
returnPreviousValues,
|
|
3625
|
-
itemSubTypes,
|
|
3626
|
-
itemType
|
|
3627
|
-
});
|
|
3628
|
-
return timeItem && { timeItem, previousItems } || { info };
|
|
3629
|
-
}
|
|
3630
|
-
|
|
3631
3659
|
const SINGLES_MATCHUP = "SINGLES";
|
|
3632
3660
|
const SINGLES$1 = "SINGLES";
|
|
3633
3661
|
const DOUBLES_MATCHUP = "DOUBLES";
|
|
@@ -5528,23 +5556,6 @@ function getVenueData({ tournamentRecord, venueId }) {
|
|
|
5528
5556
|
return { ...SUCCESS, venueData: makeDeepCopy(venueData, false, true) };
|
|
5529
5557
|
}
|
|
5530
5558
|
|
|
5531
|
-
const CHECK_IN = "CHECK_IN";
|
|
5532
|
-
const CHECK_OUT = "CHECK_OUT";
|
|
5533
|
-
const ASSIGN_VENUE = "SCHEDULE.ASSIGNMENT.VENUE";
|
|
5534
|
-
const ALLOCATE_COURTS = "SCHEDULE.ALLOCATION.COURTS";
|
|
5535
|
-
const ASSIGN_COURT = "SCHEDULE.ASSIGNMENT.COURT";
|
|
5536
|
-
const COURT_ORDER = "SCHEDULE.COURT.ORDER";
|
|
5537
|
-
const SCHEDULED_DATE = "SCHEDULE.DATE";
|
|
5538
|
-
const SCHEDULED_TIME = "SCHEDULE.TIME.SCHEDULED";
|
|
5539
|
-
const START_TIME = "SCHEDULE.TIME.START";
|
|
5540
|
-
const STOP_TIME = "SCHEDULE.TIME.STOP";
|
|
5541
|
-
const RESUME_TIME = "SCHEDULE.TIME.RESUME";
|
|
5542
|
-
const END_TIME = "SCHEDULE.TIME.END";
|
|
5543
|
-
const TIME_MODIFIERS = "SCHEDULE.TIME.MODIFIERS";
|
|
5544
|
-
const PUBLISH = "PUBLISH";
|
|
5545
|
-
const PUBLIC = "PUBLIC";
|
|
5546
|
-
const STATUS$1 = "STATUS";
|
|
5547
|
-
|
|
5548
5559
|
function getTimeStamp(item) {
|
|
5549
5560
|
return !item.createdAt ? 0 : new Date(item.createdAt).getTime();
|
|
5550
5561
|
}
|
|
@@ -5762,8 +5773,10 @@ function getMatchUpScheduleDetails({
|
|
|
5762
5773
|
scheduleVisibilityFilters,
|
|
5763
5774
|
afterRecoveryTimes,
|
|
5764
5775
|
tournamentRecord,
|
|
5776
|
+
usePublishState,
|
|
5765
5777
|
scheduleTiming,
|
|
5766
5778
|
matchUpFormat,
|
|
5779
|
+
publishStatus,
|
|
5767
5780
|
matchUpType,
|
|
5768
5781
|
matchUp,
|
|
5769
5782
|
event
|
|
@@ -5880,15 +5893,36 @@ function getMatchUpScheduleDetails({
|
|
|
5880
5893
|
});
|
|
5881
5894
|
} else {
|
|
5882
5895
|
schedule = definedAttributes({
|
|
5883
|
-
|
|
5896
|
+
milliseconds,
|
|
5884
5897
|
startTime,
|
|
5885
5898
|
endTime,
|
|
5886
|
-
|
|
5899
|
+
time
|
|
5887
5900
|
});
|
|
5888
5901
|
}
|
|
5889
|
-
const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
|
|
5890
5902
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
5891
5903
|
const { scheduledTime } = scheduledMatchUpTime({ matchUp });
|
|
5904
|
+
if (usePublishState && publishStatus?.displaySettings?.draws) {
|
|
5905
|
+
const drawSettings = publishStatus.displaySettings.draws;
|
|
5906
|
+
const scheduleDetails = (drawSettings?.[matchUp.drawId] ?? drawSettings?.default)?.scheduleDetails;
|
|
5907
|
+
if (scheduleDetails) {
|
|
5908
|
+
const scheduleAttributes = (scheduleDetails.find(
|
|
5909
|
+
(details) => scheduledDate && details.dates?.includes(scheduledDate)
|
|
5910
|
+
) ?? scheduleDetails.find((details) => !details.dates?.length))?.attributes;
|
|
5911
|
+
if (scheduleAttributes) {
|
|
5912
|
+
const template = Object.assign(
|
|
5913
|
+
{},
|
|
5914
|
+
...Object.keys(schedule).map((key) => ({ [key]: true })),
|
|
5915
|
+
// overwrite with publishStatus attributes
|
|
5916
|
+
scheduleAttributes
|
|
5917
|
+
);
|
|
5918
|
+
schedule = attributeFilter({
|
|
5919
|
+
source: schedule,
|
|
5920
|
+
template
|
|
5921
|
+
});
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5925
|
+
const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
|
|
5892
5926
|
const endDate = hasCompletedStatus && (extractDate(endTime) || extractDate(scheduledDate) || extractDate(scheduledTime)) || void 0;
|
|
5893
5927
|
return { schedule, endDate };
|
|
5894
5928
|
}
|
|
@@ -6970,6 +7004,7 @@ function getAllStructureMatchUps({
|
|
|
6970
7004
|
policyDefinitions,
|
|
6971
7005
|
tournamentRecord,
|
|
6972
7006
|
seedAssignments,
|
|
7007
|
+
usePublishState,
|
|
6973
7008
|
contextFilters,
|
|
6974
7009
|
contextContent,
|
|
6975
7010
|
matchUpFilters,
|
|
@@ -6977,6 +7012,7 @@ function getAllStructureMatchUps({
|
|
|
6977
7012
|
scheduleTiming,
|
|
6978
7013
|
contextProfile,
|
|
6979
7014
|
drawDefinition,
|
|
7015
|
+
publishStatus,
|
|
6980
7016
|
context = {},
|
|
6981
7017
|
exitProfiles,
|
|
6982
7018
|
matchUpsMap,
|
|
@@ -7085,6 +7121,8 @@ function getAllStructureMatchUps({
|
|
|
7085
7121
|
roundNamingProfile,
|
|
7086
7122
|
initialRoundOfPlay,
|
|
7087
7123
|
appliedPolicies,
|
|
7124
|
+
usePublishState,
|
|
7125
|
+
publishStatus,
|
|
7088
7126
|
isRoundRobin,
|
|
7089
7127
|
roundProfile,
|
|
7090
7128
|
matchUp,
|
|
@@ -7154,6 +7192,8 @@ function getAllStructureMatchUps({
|
|
|
7154
7192
|
tieDrawPositions,
|
|
7155
7193
|
appliedPolicies: appliedPolicies2,
|
|
7156
7194
|
isCollectionBye,
|
|
7195
|
+
usePublishState: usePublishState2,
|
|
7196
|
+
publishStatus: publishStatus2,
|
|
7157
7197
|
matchUpTieId,
|
|
7158
7198
|
isRoundRobin: isRoundRobin2,
|
|
7159
7199
|
roundProfile: roundProfile2,
|
|
@@ -7179,8 +7219,10 @@ function getAllStructureMatchUps({
|
|
|
7179
7219
|
scheduleVisibilityFilters: scheduleVisibilityFilters2,
|
|
7180
7220
|
afterRecoveryTimes,
|
|
7181
7221
|
tournamentRecord,
|
|
7222
|
+
usePublishState: usePublishState2,
|
|
7182
7223
|
scheduleTiming,
|
|
7183
7224
|
matchUpFormat,
|
|
7225
|
+
publishStatus: publishStatus2,
|
|
7184
7226
|
matchUpType,
|
|
7185
7227
|
matchUp,
|
|
7186
7228
|
event: event2
|
|
@@ -7303,7 +7345,7 @@ function getAllStructureMatchUps({
|
|
|
7303
7345
|
Object.assign(matchUpWithContext, makeDeepCopy({ sides }, true, true));
|
|
7304
7346
|
}
|
|
7305
7347
|
if (tournamentParticipants && matchUpWithContext.sides) {
|
|
7306
|
-
const participantAttributes =
|
|
7348
|
+
const participantAttributes = appliedPolicies2?.[POLICY_TYPE_PARTICIPANT];
|
|
7307
7349
|
const getMappedParticipant = (participantId) => {
|
|
7308
7350
|
const participant = participantMap?.[participantId]?.participant;
|
|
7309
7351
|
return participant && attributeFilter({
|
|
@@ -7419,6 +7461,8 @@ function getAllStructureMatchUps({
|
|
|
7419
7461
|
additionalContext: additionalContext2,
|
|
7420
7462
|
appliedPolicies: appliedPolicies2,
|
|
7421
7463
|
isCollectionBye: isCollectionBye2,
|
|
7464
|
+
usePublishState: usePublishState2,
|
|
7465
|
+
publishStatus: publishStatus2,
|
|
7422
7466
|
matchUpTieId: matchUpTieId2,
|
|
7423
7467
|
isRoundRobin: isRoundRobin2,
|
|
7424
7468
|
roundProfile: roundProfile2,
|
|
@@ -7456,11 +7500,13 @@ function getStructureMatchUps({
|
|
|
7456
7500
|
afterRecoveryTimes,
|
|
7457
7501
|
policyDefinitions,
|
|
7458
7502
|
tournamentRecord,
|
|
7503
|
+
usePublishState,
|
|
7459
7504
|
matchUpFilters,
|
|
7460
7505
|
contextFilters,
|
|
7461
7506
|
contextContent,
|
|
7462
7507
|
participantMap,
|
|
7463
7508
|
scheduleTiming,
|
|
7509
|
+
publishStatus,
|
|
7464
7510
|
contextProfile,
|
|
7465
7511
|
drawDefinition,
|
|
7466
7512
|
exitProfiles,
|
|
@@ -7481,13 +7527,15 @@ function getStructureMatchUps({
|
|
|
7481
7527
|
afterRecoveryTimes,
|
|
7482
7528
|
policyDefinitions,
|
|
7483
7529
|
tournamentRecord,
|
|
7484
|
-
|
|
7530
|
+
usePublishState,
|
|
7485
7531
|
matchUpFilters,
|
|
7486
7532
|
contextFilters,
|
|
7487
|
-
contextProfile,
|
|
7488
7533
|
contextContent,
|
|
7489
7534
|
participantMap,
|
|
7490
7535
|
scheduleTiming,
|
|
7536
|
+
publishStatus,
|
|
7537
|
+
contextProfile,
|
|
7538
|
+
drawDefinition,
|
|
7491
7539
|
exitProfiles,
|
|
7492
7540
|
matchUpsMap,
|
|
7493
7541
|
structure,
|
|
@@ -7583,12 +7631,14 @@ function getDrawMatchUps(params) {
|
|
|
7583
7631
|
afterRecoveryTimes,
|
|
7584
7632
|
policyDefinitions,
|
|
7585
7633
|
tournamentRecord,
|
|
7634
|
+
usePublishState,
|
|
7586
7635
|
contextFilters,
|
|
7587
|
-
contextProfile,
|
|
7588
|
-
drawDefinition,
|
|
7589
7636
|
matchUpFilters,
|
|
7590
7637
|
scheduleTiming,
|
|
7591
7638
|
participantMap,
|
|
7639
|
+
publishStatus,
|
|
7640
|
+
contextProfile,
|
|
7641
|
+
drawDefinition,
|
|
7592
7642
|
nextMatchUps,
|
|
7593
7643
|
inContext,
|
|
7594
7644
|
context,
|
|
@@ -7643,9 +7693,11 @@ function getDrawMatchUps(params) {
|
|
|
7643
7693
|
afterRecoveryTimes,
|
|
7644
7694
|
policyDefinitions,
|
|
7645
7695
|
tournamentRecord,
|
|
7696
|
+
usePublishState,
|
|
7697
|
+
contextContent,
|
|
7646
7698
|
participantMap,
|
|
7647
7699
|
scheduleTiming,
|
|
7648
|
-
|
|
7700
|
+
publishStatus,
|
|
7649
7701
|
contextProfile,
|
|
7650
7702
|
drawDefinition,
|
|
7651
7703
|
exitProfiles,
|
|
@@ -7962,9 +8014,10 @@ function tournamentMatchUps(params) {
|
|
|
7962
8014
|
useParticipantMap,
|
|
7963
8015
|
tournamentRecord,
|
|
7964
8016
|
inContext = true,
|
|
8017
|
+
usePublishState,
|
|
7965
8018
|
contextFilters,
|
|
7966
|
-
contextProfile,
|
|
7967
8019
|
matchUpFilters,
|
|
8020
|
+
contextProfile,
|
|
7968
8021
|
nextMatchUps,
|
|
7969
8022
|
context
|
|
7970
8023
|
} = params;
|
|
@@ -8002,6 +8055,7 @@ function tournamentMatchUps(params) {
|
|
|
8002
8055
|
afterRecoveryTimes,
|
|
8003
8056
|
policyDefinitions,
|
|
8004
8057
|
tournamentRecord,
|
|
8058
|
+
usePublishState,
|
|
8005
8059
|
contextFilters,
|
|
8006
8060
|
contextProfile,
|
|
8007
8061
|
contextContent,
|
|
@@ -8047,9 +8101,10 @@ function eventMatchUps(params) {
|
|
|
8047
8101
|
policyDefinitions,
|
|
8048
8102
|
useParticipantMap,
|
|
8049
8103
|
tournamentRecord,
|
|
8104
|
+
usePublishState,
|
|
8050
8105
|
contextFilters,
|
|
8051
|
-
contextProfile,
|
|
8052
8106
|
matchUpFilters,
|
|
8107
|
+
contextProfile,
|
|
8053
8108
|
nextMatchUps,
|
|
8054
8109
|
tournamentId,
|
|
8055
8110
|
inContext,
|
|
@@ -8092,6 +8147,7 @@ function eventMatchUps(params) {
|
|
|
8092
8147
|
contextProfile,
|
|
8093
8148
|
event
|
|
8094
8149
|
});
|
|
8150
|
+
const publishStatus = getEventPublishStatus({ event });
|
|
8095
8151
|
const drawDefinitions = event.drawDefinitions ?? [];
|
|
8096
8152
|
const eventResult = drawDefinitions.reduce((results, drawDefinition) => {
|
|
8097
8153
|
const drawMatchUpsResult = getDrawMatchUps({
|
|
@@ -8103,12 +8159,14 @@ function eventMatchUps(params) {
|
|
|
8103
8159
|
afterRecoveryTimes,
|
|
8104
8160
|
policyDefinitions,
|
|
8105
8161
|
tournamentRecord,
|
|
8106
|
-
|
|
8162
|
+
usePublishState,
|
|
8107
8163
|
contextContent,
|
|
8108
8164
|
contextFilters,
|
|
8109
|
-
contextProfile,
|
|
8110
8165
|
matchUpFilters,
|
|
8111
8166
|
participantMap,
|
|
8167
|
+
publishStatus,
|
|
8168
|
+
contextProfile,
|
|
8169
|
+
drawDefinition,
|
|
8112
8170
|
nextMatchUps,
|
|
8113
8171
|
inContext,
|
|
8114
8172
|
event
|
|
@@ -8134,12 +8192,14 @@ function drawMatchUps({
|
|
|
8134
8192
|
policyDefinitions,
|
|
8135
8193
|
useParticipantMap,
|
|
8136
8194
|
tournamentRecord,
|
|
8195
|
+
usePublishState,
|
|
8137
8196
|
contextFilters,
|
|
8138
|
-
contextProfile,
|
|
8139
8197
|
contextContent,
|
|
8140
|
-
drawDefinition,
|
|
8141
8198
|
matchUpFilters,
|
|
8142
8199
|
participantMap,
|
|
8200
|
+
publishStatus,
|
|
8201
|
+
contextProfile,
|
|
8202
|
+
drawDefinition,
|
|
8143
8203
|
nextMatchUps,
|
|
8144
8204
|
tournamentId,
|
|
8145
8205
|
inContext,
|
|
@@ -8190,12 +8250,14 @@ function drawMatchUps({
|
|
|
8190
8250
|
afterRecoveryTimes,
|
|
8191
8251
|
policyDefinitions,
|
|
8192
8252
|
tournamentRecord,
|
|
8253
|
+
usePublishState,
|
|
8193
8254
|
participantMap,
|
|
8194
|
-
|
|
8195
|
-
matchUpFilters,
|
|
8255
|
+
contextContent,
|
|
8196
8256
|
contextFilters,
|
|
8257
|
+
matchUpFilters,
|
|
8258
|
+
publishStatus,
|
|
8197
8259
|
contextProfile,
|
|
8198
|
-
|
|
8260
|
+
drawDefinition,
|
|
8199
8261
|
nextMatchUps,
|
|
8200
8262
|
inContext,
|
|
8201
8263
|
event
|
|
@@ -10836,6 +10898,11 @@ function getMatchUpDailyLimits({
|
|
|
10836
10898
|
return { matchUpDailyLimits: dailyLimits };
|
|
10837
10899
|
}
|
|
10838
10900
|
|
|
10901
|
+
function getDrawPublishStatus({ drawDetails, drawId }) {
|
|
10902
|
+
const details = drawDetails?.[drawId]?.publishingDetail;
|
|
10903
|
+
return details?.published;
|
|
10904
|
+
}
|
|
10905
|
+
|
|
10839
10906
|
function scheduledSortedMatchUps({
|
|
10840
10907
|
schedulingProfile,
|
|
10841
10908
|
matchUps = []
|
|
@@ -10977,6 +11044,7 @@ function competitionMatchUps({
|
|
|
10977
11044
|
participantsProfile,
|
|
10978
11045
|
tournamentRecords,
|
|
10979
11046
|
policyDefinitions,
|
|
11047
|
+
usePublishState,
|
|
10980
11048
|
matchUpFilters,
|
|
10981
11049
|
contextFilters,
|
|
10982
11050
|
nextMatchUps,
|
|
@@ -10992,6 +11060,7 @@ function competitionMatchUps({
|
|
|
10992
11060
|
participantsProfile,
|
|
10993
11061
|
policyDefinitions,
|
|
10994
11062
|
tournamentRecord,
|
|
11063
|
+
usePublishState,
|
|
10995
11064
|
matchUpFilters,
|
|
10996
11065
|
contextFilters,
|
|
10997
11066
|
nextMatchUps,
|
|
@@ -11037,11 +11106,10 @@ function competitionScheduleMatchUps(params) {
|
|
|
11037
11106
|
status = PUBLIC,
|
|
11038
11107
|
sortCourtsData
|
|
11039
11108
|
} = params;
|
|
11040
|
-
const
|
|
11109
|
+
const tournamentPublishStatus = usePublishState ? getTournamentTimeItem({
|
|
11041
11110
|
tournamentRecord: tournamentRecords[activeTournamentId ?? getTournamentId()],
|
|
11042
11111
|
itemType: `${PUBLISH}.${STATUS$1}`
|
|
11043
|
-
}).timeItem : void 0;
|
|
11044
|
-
const publishStatus = timeItem?.itemValue?.[status];
|
|
11112
|
+
}).timeItem?.itemValue?.[status] : void 0;
|
|
11045
11113
|
const allCompletedMatchUps = alwaysReturnCompleted ? competitionMatchUps({
|
|
11046
11114
|
...params,
|
|
11047
11115
|
matchUpFilters: {
|
|
@@ -11050,7 +11118,7 @@ function competitionScheduleMatchUps(params) {
|
|
|
11050
11118
|
},
|
|
11051
11119
|
contextFilters: params.contextFilters
|
|
11052
11120
|
}).completedMatchUps : [];
|
|
11053
|
-
if (usePublishState && (!
|
|
11121
|
+
if (usePublishState && (!tournamentPublishStatus || !Object.keys(tournamentPublishStatus).length)) {
|
|
11054
11122
|
return {
|
|
11055
11123
|
completedMatchUps: allCompletedMatchUps,
|
|
11056
11124
|
dateMatchUps: [],
|
|
@@ -11058,7 +11126,12 @@ function competitionScheduleMatchUps(params) {
|
|
|
11058
11126
|
venues
|
|
11059
11127
|
};
|
|
11060
11128
|
}
|
|
11061
|
-
|
|
11129
|
+
let publishedDrawIds, detailsMap;
|
|
11130
|
+
if (usePublishState) {
|
|
11131
|
+
({ drawIds: publishedDrawIds, detailsMap } = getCompetitionPublishedDrawDetails({
|
|
11132
|
+
tournamentRecords
|
|
11133
|
+
}));
|
|
11134
|
+
}
|
|
11062
11135
|
if (publishedDrawIds?.length) {
|
|
11063
11136
|
if (!params.contextFilters)
|
|
11064
11137
|
params.contextFilters = {};
|
|
@@ -11070,34 +11143,34 @@ function competitionScheduleMatchUps(params) {
|
|
|
11070
11143
|
);
|
|
11071
11144
|
}
|
|
11072
11145
|
}
|
|
11073
|
-
if (
|
|
11146
|
+
if (tournamentPublishStatus?.eventIds?.length) {
|
|
11074
11147
|
if (!params.matchUpFilters)
|
|
11075
11148
|
params.matchUpFilters = {};
|
|
11076
11149
|
if (params.matchUpFilters?.eventIds) {
|
|
11077
11150
|
if (!params.matchUpFilters.eventIds.length) {
|
|
11078
|
-
params.matchUpFilters.eventIds =
|
|
11151
|
+
params.matchUpFilters.eventIds = tournamentPublishStatus.eventIds;
|
|
11079
11152
|
} else {
|
|
11080
11153
|
params.matchUpFilters.eventIds = params.matchUpFilters.eventIds.filter(
|
|
11081
|
-
(eventId) =>
|
|
11154
|
+
(eventId) => tournamentPublishStatus.eventIds.includes(eventId)
|
|
11082
11155
|
);
|
|
11083
11156
|
}
|
|
11084
11157
|
} else {
|
|
11085
|
-
params.matchUpFilters.eventIds =
|
|
11158
|
+
params.matchUpFilters.eventIds = tournamentPublishStatus.eventIds;
|
|
11086
11159
|
}
|
|
11087
11160
|
}
|
|
11088
|
-
if (
|
|
11161
|
+
if (tournamentPublishStatus?.scheduledDates?.length) {
|
|
11089
11162
|
if (!params.matchUpFilters)
|
|
11090
11163
|
params.matchUpFilters = {};
|
|
11091
11164
|
if (params.matchUpFilters.scheduledDates) {
|
|
11092
11165
|
if (!params.matchUpFilters.scheduledDates.length) {
|
|
11093
|
-
params.matchUpFilters.scheduledDates =
|
|
11166
|
+
params.matchUpFilters.scheduledDates = tournamentPublishStatus.scheduledDates;
|
|
11094
11167
|
} else {
|
|
11095
11168
|
params.matchUpFilters.scheduledDates = params.matchUpFilters.scheduledDates.filter(
|
|
11096
|
-
(scheduledDate) =>
|
|
11169
|
+
(scheduledDate) => tournamentPublishStatus.scheduledDates.includes(scheduledDate)
|
|
11097
11170
|
);
|
|
11098
11171
|
}
|
|
11099
11172
|
} else {
|
|
11100
|
-
params.matchUpFilters.scheduledDates =
|
|
11173
|
+
params.matchUpFilters.scheduledDates = tournamentPublishStatus.scheduledDates;
|
|
11101
11174
|
}
|
|
11102
11175
|
}
|
|
11103
11176
|
if (alwaysReturnCompleted) {
|
|
@@ -11116,10 +11189,48 @@ function competitionScheduleMatchUps(params) {
|
|
|
11116
11189
|
matchUpFilters: params.matchUpFilters,
|
|
11117
11190
|
contextFilters: params.contextFilters
|
|
11118
11191
|
});
|
|
11119
|
-
|
|
11192
|
+
let relevantMatchUps = [
|
|
11120
11193
|
...upcomingMatchUps ?? [],
|
|
11121
11194
|
...pendingMatchUps ?? []
|
|
11122
11195
|
];
|
|
11196
|
+
if (detailsMap && Object.keys(detailsMap).length) {
|
|
11197
|
+
relevantMatchUps = relevantMatchUps.filter((matchUp) => {
|
|
11198
|
+
const { drawId, structureId, stage } = matchUp;
|
|
11199
|
+
if (!detailsMap[drawId])
|
|
11200
|
+
return false;
|
|
11201
|
+
if (detailsMap[drawId].stageDetails) {
|
|
11202
|
+
const stageKeys = Object.keys(detailsMap[drawId].stageDetails);
|
|
11203
|
+
const unpublishedStages = stageKeys.filter(
|
|
11204
|
+
(stage2) => !detailsMap[drawId].stageDetails[stage2].published
|
|
11205
|
+
);
|
|
11206
|
+
const publishedStages = stageKeys.filter(
|
|
11207
|
+
(stage2) => detailsMap[drawId].stageDetails[stage2].published
|
|
11208
|
+
);
|
|
11209
|
+
if (unpublishedStages.length && unpublishedStages.includes(stage))
|
|
11210
|
+
return false;
|
|
11211
|
+
if (publishedStages.length && publishedStages.includes(stage))
|
|
11212
|
+
return true;
|
|
11213
|
+
return unpublishedStages.length && !unpublishedStages.includes(stage) && !publishedStages.length;
|
|
11214
|
+
}
|
|
11215
|
+
if (detailsMap[drawId].structureDetails) {
|
|
11216
|
+
const structureIdKeys = Object.keys(
|
|
11217
|
+
detailsMap[drawId].structureDetails
|
|
11218
|
+
);
|
|
11219
|
+
const unpublishedStructureIds = structureIdKeys.filter(
|
|
11220
|
+
(structureId2) => !detailsMap[drawId].structureDetails[structureId2].published
|
|
11221
|
+
);
|
|
11222
|
+
const publishedStructureIds = structureIdKeys.filter(
|
|
11223
|
+
(structureId2) => detailsMap[drawId].structureDetails[structureId2].published
|
|
11224
|
+
);
|
|
11225
|
+
if (unpublishedStructureIds.length && unpublishedStructureIds.includes(structureId))
|
|
11226
|
+
return false;
|
|
11227
|
+
if (publishedStructureIds.length && publishedStructureIds.includes(structureId))
|
|
11228
|
+
return true;
|
|
11229
|
+
return unpublishedStructureIds.length && !unpublishedStructureIds.includes(structureId) && !publishedStructureIds.length;
|
|
11230
|
+
}
|
|
11231
|
+
return true;
|
|
11232
|
+
});
|
|
11233
|
+
}
|
|
11123
11234
|
const dateMatchUps = sortDateMatchUps ? scheduledSortedMatchUps({ matchUps: relevantMatchUps, schedulingProfile }) : relevantMatchUps;
|
|
11124
11235
|
const courtsData = courts?.map((court) => {
|
|
11125
11236
|
const matchUps = getCourtMatchUps(court);
|
|
@@ -11130,11 +11241,11 @@ function competitionScheduleMatchUps(params) {
|
|
|
11130
11241
|
};
|
|
11131
11242
|
});
|
|
11132
11243
|
const result = {
|
|
11133
|
-
courtsData,
|
|
11134
11244
|
completedMatchUps: alwaysReturnCompleted ? allCompletedMatchUps : completedMatchUps,
|
|
11135
11245
|
// completed matchUps for the filter date
|
|
11136
11246
|
dateMatchUps,
|
|
11137
11247
|
// all incomplete matchUps for the filter date
|
|
11248
|
+
courtsData,
|
|
11138
11249
|
groupInfo,
|
|
11139
11250
|
venues
|
|
11140
11251
|
};
|
|
@@ -11158,26 +11269,28 @@ function competitionScheduleMatchUps(params) {
|
|
|
11158
11269
|
}) : courtMatchUps;
|
|
11159
11270
|
}
|
|
11160
11271
|
}
|
|
11161
|
-
function
|
|
11272
|
+
function getCompetitionPublishedDrawDetails({
|
|
11162
11273
|
tournamentRecords
|
|
11163
11274
|
}) {
|
|
11164
11275
|
const drawIds = [];
|
|
11276
|
+
const detailsMap = {};
|
|
11165
11277
|
for (const tournamentRecord of Object.values(tournamentRecords)) {
|
|
11166
11278
|
for (const event of tournamentRecord.events ?? []) {
|
|
11167
|
-
const
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11279
|
+
const eventPubStatus = getEventPublishStatus({ event });
|
|
11280
|
+
const drawDetails = eventPubStatus?.drawDetails;
|
|
11281
|
+
if (isObject(drawDetails)) {
|
|
11282
|
+
Object.assign(detailsMap, drawDetails);
|
|
11283
|
+
drawIds.push(
|
|
11284
|
+
...Object.keys(drawDetails).filter(
|
|
11285
|
+
(drawId) => getDrawPublishStatus({ drawId, drawDetails })
|
|
11286
|
+
)
|
|
11287
|
+
);
|
|
11288
|
+
} else if (eventPubStatus?.drawIds?.length) {
|
|
11289
|
+
drawIds.push(...eventPubStatus.drawIds);
|
|
11177
11290
|
}
|
|
11178
11291
|
}
|
|
11179
11292
|
}
|
|
11180
|
-
return { drawIds };
|
|
11293
|
+
return { drawIds, detailsMap };
|
|
11181
11294
|
}
|
|
11182
11295
|
|
|
11183
11296
|
const { stageOrder } = drawDefinitionConstants;
|
|
@@ -11865,13 +11978,8 @@ function getMatchUpDependencies(params) {
|
|
|
11865
11978
|
}
|
|
11866
11979
|
|
|
11867
11980
|
function getEventPublishStatuses({ event }) {
|
|
11868
|
-
const
|
|
11869
|
-
|
|
11870
|
-
element: event,
|
|
11871
|
-
itemType
|
|
11872
|
-
});
|
|
11873
|
-
if (timeItem?.itemValue?.PUBLIC) {
|
|
11874
|
-
const { drawIds: publishedDrawIds = [], seeding } = timeItem.itemValue.PUBLIC || {};
|
|
11981
|
+
const eventPubStatus = getEventPublishStatus({ event });
|
|
11982
|
+
if (eventPubStatus) {
|
|
11875
11983
|
const publishedSeeding = {
|
|
11876
11984
|
published: void 0,
|
|
11877
11985
|
// seeding can be present for all entries in an event when no flights have been defined
|
|
@@ -11879,9 +11987,13 @@ function getEventPublishStatuses({ event }) {
|
|
|
11879
11987
|
drawIds: []
|
|
11880
11988
|
// seeding can be specific to drawIds
|
|
11881
11989
|
};
|
|
11882
|
-
if (seeding) {
|
|
11883
|
-
Object.assign(publishedSeeding,
|
|
11990
|
+
if (eventPubStatus.seeding) {
|
|
11991
|
+
Object.assign(publishedSeeding, eventPubStatus.seeding);
|
|
11884
11992
|
}
|
|
11993
|
+
const { drawDetails, drawIds } = eventPubStatus;
|
|
11994
|
+
const publishedDrawIds = drawDetails && Object.keys(drawDetails).filter(
|
|
11995
|
+
(drawId) => getDrawPublishStatus({ drawDetails, drawId })
|
|
11996
|
+
) || drawIds || [];
|
|
11885
11997
|
return {
|
|
11886
11998
|
publishedDrawIds,
|
|
11887
11999
|
publishedSeeding
|
|
@@ -11967,6 +12079,10 @@ function getEventSeedAssignments({
|
|
|
11967
12079
|
return eventSeedAssignments;
|
|
11968
12080
|
}
|
|
11969
12081
|
|
|
12082
|
+
function stringSort(a, b) {
|
|
12083
|
+
return (a || "").localeCompare(b || "");
|
|
12084
|
+
}
|
|
12085
|
+
|
|
11970
12086
|
function processEventEntry({
|
|
11971
12087
|
convertExtensions,
|
|
11972
12088
|
seedAssignments,
|
|
@@ -12838,7 +12954,7 @@ function getParticipantEntries(params) {
|
|
|
12838
12954
|
const itemIsPrior = consideredMinutes >= scheduledMinutes;
|
|
12839
12955
|
const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : itemIsPrior && timeStringMinutes(consideredItem.scheduledTime) < timeStringMinutes(notBeforeTime);
|
|
12840
12956
|
if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
|
|
12841
|
-
const key = [scheduleItem.matchUpId, consideredItem.matchUpId].sort().join("|");
|
|
12957
|
+
const key = [scheduleItem.matchUpId, consideredItem.matchUpId].sort(stringSort).join("|");
|
|
12842
12958
|
participantAggregator.scheduleConflicts[key] = {
|
|
12843
12959
|
priorScheduledMatchUpId: scheduleItem.matchUpId,
|
|
12844
12960
|
matchUpIdWithConflict: consideredItem.matchUpId
|
|
@@ -14533,12 +14649,12 @@ function positionActions$1(params) {
|
|
|
14533
14649
|
const isActiveDrawPosition = activeDrawPositions.includes(drawPosition);
|
|
14534
14650
|
if (actionsDisabled)
|
|
14535
14651
|
return {
|
|
14652
|
+
hasPositionAssigned: !!positionAssignment,
|
|
14536
14653
|
info: "Actions Disabled for structure",
|
|
14537
|
-
isByePosition,
|
|
14538
14654
|
isActiveDrawPosition,
|
|
14539
14655
|
isDrawPosition: true,
|
|
14540
|
-
|
|
14541
|
-
|
|
14656
|
+
validActions: [],
|
|
14657
|
+
isByePosition
|
|
14542
14658
|
};
|
|
14543
14659
|
if (isAvailableAction({ policyActions, action: ASSIGN_PARTICIPANT }) && !isActiveDrawPosition && positionAssignments && !disablePlacementActions && (!positionAssignment || isByePosition)) {
|
|
14544
14660
|
const { validAssignmentActions } = getValidAssignmentActions({
|
|
@@ -14920,7 +15036,9 @@ function getDrawData(params) {
|
|
|
14920
15036
|
policyDefinitions,
|
|
14921
15037
|
tournamentRecord,
|
|
14922
15038
|
inContext = true,
|
|
15039
|
+
usePublishState,
|
|
14923
15040
|
drawDefinition,
|
|
15041
|
+
publishStatus,
|
|
14924
15042
|
noDeepCopy,
|
|
14925
15043
|
sortConfig,
|
|
14926
15044
|
context,
|
|
@@ -14992,6 +15110,8 @@ function getDrawData(params) {
|
|
|
14992
15110
|
tournamentParticipants,
|
|
14993
15111
|
policyDefinitions,
|
|
14994
15112
|
tournamentRecord,
|
|
15113
|
+
usePublishState,
|
|
15114
|
+
publishStatus,
|
|
14995
15115
|
drawDefinition,
|
|
14996
15116
|
inContext,
|
|
14997
15117
|
structure,
|
|
@@ -15105,11 +15225,7 @@ function getEventData(params) {
|
|
|
15105
15225
|
return { error: MISSING_EVENT };
|
|
15106
15226
|
const { eventId } = event;
|
|
15107
15227
|
const { tournamentId, endDate } = tournamentRecord;
|
|
15108
|
-
const
|
|
15109
|
-
itemType: `${PUBLISH}.${STATUS$1}`,
|
|
15110
|
-
event
|
|
15111
|
-
});
|
|
15112
|
-
const publishStatus = timeItem?.itemValue?.[status];
|
|
15228
|
+
const publishStatus = getEventPublishStatus({ event, status });
|
|
15113
15229
|
const { participants: tournamentParticipants } = getParticipants({
|
|
15114
15230
|
withGroupings: true,
|
|
15115
15231
|
withEvents: false,
|
|
@@ -15118,9 +15234,51 @@ function getEventData(params) {
|
|
|
15118
15234
|
// order is important!!
|
|
15119
15235
|
tournamentRecord
|
|
15120
15236
|
});
|
|
15121
|
-
const stageFilter = ({ stage }) =>
|
|
15122
|
-
|
|
15123
|
-
|
|
15237
|
+
const stageFilter = ({ stage, drawId }) => {
|
|
15238
|
+
if (!usePublishState)
|
|
15239
|
+
return true;
|
|
15240
|
+
const stageDetails = publishStatus?.drawDetails?.[drawId]?.stageDetails;
|
|
15241
|
+
if (!stageDetails || !Object.keys(stageDetails).length)
|
|
15242
|
+
return true;
|
|
15243
|
+
return stageDetails[stage]?.published;
|
|
15244
|
+
};
|
|
15245
|
+
const structureFilter = ({ structureId, drawId }) => {
|
|
15246
|
+
if (!usePublishState)
|
|
15247
|
+
return true;
|
|
15248
|
+
const structureDetails = publishStatus?.drawDetails?.[drawId]?.structureDetails;
|
|
15249
|
+
if (!structureDetails || !Object.keys(structureDetails).length)
|
|
15250
|
+
return true;
|
|
15251
|
+
return structureDetails[structureId]?.published;
|
|
15252
|
+
};
|
|
15253
|
+
const drawFilter = ({ drawId }) => {
|
|
15254
|
+
if (!usePublishState)
|
|
15255
|
+
return true;
|
|
15256
|
+
if (publishStatus.drawDetails) {
|
|
15257
|
+
return publishStatus.drawDetails[drawId]?.publishingDetail?.published;
|
|
15258
|
+
} else if (publishStatus.drawIds) {
|
|
15259
|
+
return publishStatus.drawIds.includes(drawId);
|
|
15260
|
+
}
|
|
15261
|
+
return true;
|
|
15262
|
+
};
|
|
15263
|
+
const roundLimitMapper = ({ drawId, structure }) => {
|
|
15264
|
+
if (!usePublishState)
|
|
15265
|
+
return structure;
|
|
15266
|
+
const roundLimit = publishStatus?.drawDetails?.[drawId]?.structureDetails?.[structure.structureId]?.roundLimit;
|
|
15267
|
+
if (isConvertableInteger(roundLimit)) {
|
|
15268
|
+
const roundNumbers = generateRange(1, roundLimit + 1);
|
|
15269
|
+
const roundMatchUps = {};
|
|
15270
|
+
const roundProfile = {};
|
|
15271
|
+
for (const roundNumber of roundNumbers) {
|
|
15272
|
+
if (structure.roundMatchUps[roundNumber]) {
|
|
15273
|
+
roundMatchUps[roundNumber] = structure.roundMatchUps[roundNumber];
|
|
15274
|
+
roundProfile[roundNumber] = structure.roundProfile[roundNumber];
|
|
15275
|
+
}
|
|
15276
|
+
}
|
|
15277
|
+
structure.roundMatchUps = roundMatchUps;
|
|
15278
|
+
structure.roundProfile = roundProfile;
|
|
15279
|
+
}
|
|
15280
|
+
return structure;
|
|
15281
|
+
};
|
|
15124
15282
|
const drawDefinitions = event.drawDefinitions || [];
|
|
15125
15283
|
const drawsData = drawDefinitions.filter(drawFilter).map(
|
|
15126
15284
|
(drawDefinition) => (({ drawInfo, structures }) => ({
|
|
@@ -15134,15 +15292,24 @@ function getEventData(params) {
|
|
|
15134
15292
|
noDeepCopy: true,
|
|
15135
15293
|
policyDefinitions,
|
|
15136
15294
|
tournamentRecord,
|
|
15295
|
+
usePublishState,
|
|
15137
15296
|
drawDefinition,
|
|
15297
|
+
publishStatus,
|
|
15138
15298
|
sortConfig,
|
|
15139
15299
|
event
|
|
15140
15300
|
})
|
|
15141
15301
|
)
|
|
15142
|
-
).map(({ structures, ...drawData }) =>
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15302
|
+
).map(({ structures, ...drawData }) => {
|
|
15303
|
+
const filteredStructures = structures?.filter(
|
|
15304
|
+
({ stage, structureId }) => structureFilter({ structureId, drawId: drawData.drawId }) && stageFilter({ stage, drawId: drawData.drawId })
|
|
15305
|
+
).map(
|
|
15306
|
+
(structure) => roundLimitMapper({ drawId: drawData.drawId, structure })
|
|
15307
|
+
);
|
|
15308
|
+
return {
|
|
15309
|
+
...drawData,
|
|
15310
|
+
structures: filteredStructures
|
|
15311
|
+
};
|
|
15312
|
+
}).filter((drawData) => drawData.structures?.length);
|
|
15146
15313
|
const { tournamentInfo } = getTournamentInfo({ tournamentRecord });
|
|
15147
15314
|
const venues = tournamentRecord.venues || [];
|
|
15148
15315
|
const venuesData = venues.map(
|
|
@@ -15188,10 +15355,7 @@ function getEventData(params) {
|
|
|
15188
15355
|
eventInfo,
|
|
15189
15356
|
drawsData
|
|
15190
15357
|
};
|
|
15191
|
-
eventData.eventInfo.publish =
|
|
15192
|
-
createdAt: timeItem?.createdAt,
|
|
15193
|
-
state: timeItem?.itemValue
|
|
15194
|
-
};
|
|
15358
|
+
eventData.eventInfo.publish = publishStatus;
|
|
15195
15359
|
return { ...SUCCESS, eventData };
|
|
15196
15360
|
}
|
|
15197
15361
|
|