tods-competition-factory 1.8.10 → 1.8.12
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 +21 -14
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +6 -4
- package/dist/forge/query.mjs +256 -1223
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +2664 -2657
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +3078 -3090
- 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 +2 -2
package/dist/forge/query.mjs
CHANGED
|
@@ -209,10 +209,6 @@ const POLICY_NOT_FOUND = {
|
|
|
209
209
|
message: "Policy not found",
|
|
210
210
|
code: "ERR_NOT_FOUND_POLICY"
|
|
211
211
|
};
|
|
212
|
-
const MISSING_SCORING_POLICY = {
|
|
213
|
-
message: "Missing scoring policy / matchUpFormats",
|
|
214
|
-
code: "ERR_MISSING_POLICY_SCORING_MATCHUP_FORMATS"
|
|
215
|
-
};
|
|
216
212
|
const MISSING_COURT_ID = {
|
|
217
213
|
message: "Missing courtId",
|
|
218
214
|
code: "ERR_MISSING_COURT_ID"
|
|
@@ -237,10 +233,6 @@ const MISSING_PARTICIPANT = {
|
|
|
237
233
|
message: "Missing participant",
|
|
238
234
|
code: "ERR_MISSING_PARTICIPANT"
|
|
239
235
|
};
|
|
240
|
-
const MISSING_PARTICIPANTS = {
|
|
241
|
-
message: "Missing participants",
|
|
242
|
-
code: "ERR_MISSING_PARTICIPANTS"
|
|
243
|
-
};
|
|
244
236
|
const MISSING_PARTICIPANT_ID = {
|
|
245
237
|
message: "Missing participantId",
|
|
246
238
|
code: "ERR_MISSING_PARTICIPANT_ID"
|
|
@@ -289,10 +281,6 @@ const INVALID_SCALE_ITEM = {
|
|
|
289
281
|
message: "Invalid scaleItem",
|
|
290
282
|
code: "ERR_INVALID_SCALE_ITEM"
|
|
291
283
|
};
|
|
292
|
-
const INVALID_OBJECT = {
|
|
293
|
-
message: "Invalid object",
|
|
294
|
-
code: "ERR_INVALID_OBJECT"
|
|
295
|
-
};
|
|
296
284
|
const INVALID_VALUES = {
|
|
297
285
|
message: "Invalid values",
|
|
298
286
|
code: "ERR_INVALID_VALUES"
|
|
@@ -849,70 +837,17 @@ function UUID() {
|
|
|
849
837
|
}
|
|
850
838
|
|
|
851
839
|
const APPLIED_POLICIES = "appliedPolicies";
|
|
852
|
-
const AUDIT_POSITION_ACTIONS = "positionActions";
|
|
853
840
|
const CONTEXT = "context";
|
|
854
|
-
const DELEGATED_OUTCOME = "delegatedOutcome";
|
|
855
841
|
const DISABLED = "disabled";
|
|
856
842
|
const DISABLE_LINKS = "disableLinks";
|
|
857
|
-
const DISABLE_AUTO_CALC = "disableAutoCalc";
|
|
858
|
-
const DRAW_DELETIONS = "drawDeletions";
|
|
859
|
-
const DRAW_PROFILE = "drawProfile";
|
|
860
|
-
const ENTRY_PROFILE = "entryProfile";
|
|
861
|
-
const EVENT_PROFILE = "eventProfile";
|
|
862
|
-
const FACTORY = "factory";
|
|
863
843
|
const FLIGHT_PROFILE = "flightProfile";
|
|
864
|
-
const GROUPING_ATTRIBUTE = "groupingAttribute";
|
|
865
844
|
const LINEUPS = "lineUps";
|
|
866
845
|
const LINKED_TOURNAMENTS = "linkedTournamentsIds";
|
|
867
|
-
const MATCHUP_HISTORY = "matchUpHistory";
|
|
868
|
-
const PARTICIPANT_REPRESENTATIVES = "participantRepresentatives";
|
|
869
|
-
const PERSON_REQUESTS = "personRequests";
|
|
870
|
-
const RANKING_POINTS = "rankingPoints";
|
|
871
846
|
const ROUND_TARGET = "roundTarget";
|
|
872
847
|
const SCHEDULE_LIMITS = "scheduleLimits";
|
|
873
848
|
const SCHEDULE_TIMING = "scheduleTiming";
|
|
874
849
|
const SCHEDULING_PROFILE = "schedulingProfile";
|
|
875
|
-
const STATUS_DETAIL = "statusDetail";
|
|
876
|
-
const SUB_ORDER = "subOrder";
|
|
877
850
|
const TALLY = "tally";
|
|
878
|
-
const TIE_FORMAT_MODIFICATIONS = "tieFormatModification";
|
|
879
|
-
const extensionConstants = {
|
|
880
|
-
APPLIED_POLICIES,
|
|
881
|
-
AUDIT_POSITION_ACTIONS,
|
|
882
|
-
CONTEXT,
|
|
883
|
-
// used to capture, e.g. context in which a venue was added
|
|
884
|
-
DELEGATED_OUTCOME,
|
|
885
|
-
DISABLED,
|
|
886
|
-
DISABLE_LINKS,
|
|
887
|
-
DISABLE_AUTO_CALC,
|
|
888
|
-
DRAW_DELETIONS,
|
|
889
|
-
DRAW_PROFILE,
|
|
890
|
-
ENTRY_PROFILE,
|
|
891
|
-
// used for drawGeneration; not relevant for anonymized tournaments
|
|
892
|
-
EVENT_PROFILE,
|
|
893
|
-
FLIGHT_PROFILE,
|
|
894
|
-
GROUPING_ATTRIBUTE,
|
|
895
|
-
// for generating teams; not relevant for anonymized tournaments
|
|
896
|
-
LINEUPS,
|
|
897
|
-
LINKED_TOURNAMENTS,
|
|
898
|
-
MATCHUP_HISTORY,
|
|
899
|
-
PARTICIPANT_REPRESENTATIVES,
|
|
900
|
-
PERSON_REQUESTS,
|
|
901
|
-
RANKING_POINTS,
|
|
902
|
-
// for attaching points awarded to tournamentRecord
|
|
903
|
-
ROUND_TARGET,
|
|
904
|
-
SCHEDULE_LIMITS,
|
|
905
|
-
SCHEDULE_TIMING,
|
|
906
|
-
SCHEDULING_PROFILE,
|
|
907
|
-
STATUS_DETAIL,
|
|
908
|
-
// attached to event.entries
|
|
909
|
-
SUB_ORDER,
|
|
910
|
-
TALLY,
|
|
911
|
-
TIE_FORMAT_MODIFICATIONS,
|
|
912
|
-
// for auditing, not important when anonymized
|
|
913
|
-
FACTORY
|
|
914
|
-
// used for capturing versioning of factory and other TODS document processors
|
|
915
|
-
};
|
|
916
851
|
|
|
917
852
|
function getAppliedPolicies({
|
|
918
853
|
onlySpecifiedPolicyTypes = false,
|
|
@@ -5808,7 +5743,6 @@ function matchUpEndTime({ matchUp }) {
|
|
|
5808
5743
|
|
|
5809
5744
|
const SINGLES = "SINGLES";
|
|
5810
5745
|
const TEAM = "TEAM";
|
|
5811
|
-
const TEAM_EVENT = "TEAM";
|
|
5812
5746
|
|
|
5813
5747
|
function getMatchUpScheduleDetails({
|
|
5814
5748
|
scheduleVisibilityFilters,
|
|
@@ -8787,6 +8721,199 @@ function getMatchUpFormatTimingUpdate({ tournamentRecords }) {
|
|
|
8787
8721
|
});
|
|
8788
8722
|
}
|
|
8789
8723
|
|
|
8724
|
+
const FORMAT_STANDARD = "SET3-S:6/TB7";
|
|
8725
|
+
|
|
8726
|
+
const ADULT = "ADULT";
|
|
8727
|
+
const JUNIOR = "JUNIOR";
|
|
8728
|
+
const WHEELCHAIR = "WHEELCHAIR";
|
|
8729
|
+
const POLICY_SCHEDULING_DEFAULT = {
|
|
8730
|
+
[POLICY_TYPE_SCHEDULING]: {
|
|
8731
|
+
defaultTimes: {
|
|
8732
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 90 } }],
|
|
8733
|
+
recoveryTimes: [{ minutes: { [DOUBLES]: 30, default: 60 } }]
|
|
8734
|
+
},
|
|
8735
|
+
defaultDailyLimits: {
|
|
8736
|
+
[SINGLES$1]: 2,
|
|
8737
|
+
[DOUBLES]: 2,
|
|
8738
|
+
total: 3
|
|
8739
|
+
},
|
|
8740
|
+
matchUpAverageTimes: [
|
|
8741
|
+
{
|
|
8742
|
+
matchUpFormatCodes: [FORMAT_STANDARD],
|
|
8743
|
+
// Best of 3 tiebreak sets
|
|
8744
|
+
averageTimes: [
|
|
8745
|
+
{
|
|
8746
|
+
categoryNames: [],
|
|
8747
|
+
minutes: { default: 90 }
|
|
8748
|
+
},
|
|
8749
|
+
{
|
|
8750
|
+
categoryTypes: [WHEELCHAIR],
|
|
8751
|
+
minutes: { default: 120 }
|
|
8752
|
+
}
|
|
8753
|
+
]
|
|
8754
|
+
},
|
|
8755
|
+
{
|
|
8756
|
+
matchUpFormatCodes: ["SET3-S:6/TB7-F:TB10"],
|
|
8757
|
+
// Two tiebreak sets, 10-point match tiebreak at one set all
|
|
8758
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 85 } }]
|
|
8759
|
+
},
|
|
8760
|
+
{
|
|
8761
|
+
matchUpFormatCodes: ["SET3-S:6/TB7-F:TB7"],
|
|
8762
|
+
// Two tiebreak sets, 7-point match tiebreak at one set all
|
|
8763
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 70 } }]
|
|
8764
|
+
},
|
|
8765
|
+
{
|
|
8766
|
+
matchUpFormatCodes: ["SET3-S:4NOAD-F:TB7"],
|
|
8767
|
+
// Two short sets to 4 with deciding game at 3-3, 7-point match tiebreak at one set all
|
|
8768
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 55 } }]
|
|
8769
|
+
},
|
|
8770
|
+
{
|
|
8771
|
+
matchUpFormatCodes: ["SET3-S:4/TB7"],
|
|
8772
|
+
// Best of 3 sets to 4
|
|
8773
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 60 } }]
|
|
8774
|
+
},
|
|
8775
|
+
{
|
|
8776
|
+
matchUpFormatCodes: ["SET3-S:4/TB7-F:TB7"],
|
|
8777
|
+
// Two short sets to 4, 7-point match tiebreak at one set all
|
|
8778
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 50 } }]
|
|
8779
|
+
},
|
|
8780
|
+
{
|
|
8781
|
+
matchUpFormatCodes: ["SET3-S:4/TB7-F:TB10"],
|
|
8782
|
+
// Two short sets to 4, 10-point match tiebreak at one set all
|
|
8783
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 55 } }]
|
|
8784
|
+
},
|
|
8785
|
+
{
|
|
8786
|
+
matchUpFormatCodes: ["SET3-S:4/TB5@3"],
|
|
8787
|
+
// Two out of three short sets to 4 with 5-point tiebreak at 3 games all
|
|
8788
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 45 } }]
|
|
8789
|
+
},
|
|
8790
|
+
{
|
|
8791
|
+
matchUpFormatCodes: [
|
|
8792
|
+
"SET1-S:8/TB7",
|
|
8793
|
+
"SET1-S:8/TB7@7"
|
|
8794
|
+
],
|
|
8795
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 40 } }]
|
|
8796
|
+
},
|
|
8797
|
+
{
|
|
8798
|
+
matchUpFormatCodes: ["SET1-S:5/TB9@4"],
|
|
8799
|
+
// One no advantage set to 5, tiebreak to 9 at 4-4
|
|
8800
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 30 } }]
|
|
8801
|
+
},
|
|
8802
|
+
{
|
|
8803
|
+
matchUpFormatCodes: ["SET1-S:6/TB7"],
|
|
8804
|
+
// One standard tiebreak set to 6, 7-point tiebreak at 6 games all
|
|
8805
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 30 } }]
|
|
8806
|
+
},
|
|
8807
|
+
{
|
|
8808
|
+
matchUpFormatCodes: ["SET1-S:6NOAD"],
|
|
8809
|
+
// One set to 6 with deciding game at 5 games all
|
|
8810
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 30 } }]
|
|
8811
|
+
},
|
|
8812
|
+
{
|
|
8813
|
+
matchUpFormatCodes: [
|
|
8814
|
+
"SET1-S:4/TB7",
|
|
8815
|
+
"SET1-S:4/TB5@3",
|
|
8816
|
+
"SET3-S:TB10",
|
|
8817
|
+
"SET1-S:T20"
|
|
8818
|
+
],
|
|
8819
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 20 } }]
|
|
8820
|
+
},
|
|
8821
|
+
{
|
|
8822
|
+
matchUpFormatCodes: ["SET1-S:4NOAD"],
|
|
8823
|
+
// One short set to 4, deciding game is played at 3 games all
|
|
8824
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 20 } }]
|
|
8825
|
+
},
|
|
8826
|
+
{
|
|
8827
|
+
matchUpFormatCodes: ["SET1-S:TB10"],
|
|
8828
|
+
// One 10-point tiebreak game
|
|
8829
|
+
averageTimes: [{ categoryNames: [], minutes: { default: 10 } }]
|
|
8830
|
+
}
|
|
8831
|
+
],
|
|
8832
|
+
matchUpRecoveryTimes: [
|
|
8833
|
+
{
|
|
8834
|
+
matchUpFormatCodes: [
|
|
8835
|
+
"SET3-S:6/TB7",
|
|
8836
|
+
"SET3-S:6/TB7-F:TB10",
|
|
8837
|
+
"SET3-S:6/TB7-F:TB7"
|
|
8838
|
+
],
|
|
8839
|
+
recoveryTimes: [
|
|
8840
|
+
{
|
|
8841
|
+
categoryTypes: [ADULT, WHEELCHAIR],
|
|
8842
|
+
minutes: { default: 60, [DOUBLES]: 30 }
|
|
8843
|
+
},
|
|
8844
|
+
{
|
|
8845
|
+
categoryTypes: [JUNIOR],
|
|
8846
|
+
minutes: { default: 60, [DOUBLES]: 60 }
|
|
8847
|
+
}
|
|
8848
|
+
]
|
|
8849
|
+
},
|
|
8850
|
+
{
|
|
8851
|
+
matchUpFormatCodes: [
|
|
8852
|
+
"SET3-S:4/TB7-F:TB7",
|
|
8853
|
+
"SET3-S:4/TB7-F:TB10",
|
|
8854
|
+
"SET3-S:4NOAD-F:TB7",
|
|
8855
|
+
"SET3-S:4/TB7",
|
|
8856
|
+
"SET3-S:4/TB5@3"
|
|
8857
|
+
],
|
|
8858
|
+
recoveryTimes: [
|
|
8859
|
+
{
|
|
8860
|
+
categoryTypes: [ADULT, WHEELCHAIR],
|
|
8861
|
+
minutes: { default: 30 }
|
|
8862
|
+
},
|
|
8863
|
+
{
|
|
8864
|
+
categoryTypes: [JUNIOR],
|
|
8865
|
+
minutes: { default: 60 }
|
|
8866
|
+
}
|
|
8867
|
+
]
|
|
8868
|
+
},
|
|
8869
|
+
{
|
|
8870
|
+
matchUpFormatCodes: [
|
|
8871
|
+
"SET1-S:8/TB7",
|
|
8872
|
+
"SET1-S:8/TB7@7",
|
|
8873
|
+
"SET1-S:5/TB9@4",
|
|
8874
|
+
"SET1-S:6/TB7",
|
|
8875
|
+
"SET1-S:6NOAD",
|
|
8876
|
+
"SET1-S:4/TB7",
|
|
8877
|
+
"SET1-S:4NOAD",
|
|
8878
|
+
"SET3-S:TB10",
|
|
8879
|
+
"SET1-S:T20"
|
|
8880
|
+
],
|
|
8881
|
+
recoveryTimes: [
|
|
8882
|
+
{
|
|
8883
|
+
categoryNames: [],
|
|
8884
|
+
minutes: { default: 30 }
|
|
8885
|
+
}
|
|
8886
|
+
]
|
|
8887
|
+
},
|
|
8888
|
+
{
|
|
8889
|
+
matchUpFormatCodes: ["SET1-S:4/TB5@3"],
|
|
8890
|
+
// One short set to 4, 5-point tiebreak at 3 games all
|
|
8891
|
+
recoveryTimes: [
|
|
8892
|
+
{
|
|
8893
|
+
categoryTypes: [ADULT, JUNIOR],
|
|
8894
|
+
minutes: { default: 30 }
|
|
8895
|
+
},
|
|
8896
|
+
{
|
|
8897
|
+
categoryTypes: [WHEELCHAIR],
|
|
8898
|
+
minutes: { default: 15 }
|
|
8899
|
+
}
|
|
8900
|
+
]
|
|
8901
|
+
},
|
|
8902
|
+
{
|
|
8903
|
+
matchUpFormatCodes: ["SET1-S:TB10"],
|
|
8904
|
+
// One 10-point tiebreak game
|
|
8905
|
+
recoveryTimes: [
|
|
8906
|
+
{
|
|
8907
|
+
categoryNames: [],
|
|
8908
|
+
minutes: { default: 15 }
|
|
8909
|
+
}
|
|
8910
|
+
]
|
|
8911
|
+
}
|
|
8912
|
+
],
|
|
8913
|
+
matchUpDailyLimits: []
|
|
8914
|
+
}
|
|
8915
|
+
};
|
|
8916
|
+
|
|
8790
8917
|
function getEventMatchUpFormatTiming$1({
|
|
8791
8918
|
tournamentRecord,
|
|
8792
8919
|
matchUpFormats,
|
|
@@ -8800,6 +8927,7 @@ function getEventMatchUpFormatTiming$1({
|
|
|
8800
8927
|
if (!event)
|
|
8801
8928
|
return { error: MISSING_EVENT };
|
|
8802
8929
|
let matchUpFormatDefinitions = [];
|
|
8930
|
+
let info;
|
|
8803
8931
|
if (!matchUpFormats?.length) {
|
|
8804
8932
|
const { policy } = findPolicy({
|
|
8805
8933
|
policyType: POLICY_TYPE_SCORING,
|
|
@@ -8813,20 +8941,19 @@ function getEventMatchUpFormatTiming$1({
|
|
|
8813
8941
|
name: SCHEDULE_TIMING,
|
|
8814
8942
|
event
|
|
8815
8943
|
});
|
|
8944
|
+
let matchUpAverageTimes, matchUpRecoveryTimes;
|
|
8816
8945
|
if (extension?.value) {
|
|
8817
|
-
|
|
8818
|
-
[
|
|
8819
|
-
...(extension.value.matchUpAverageTimes || []).map(
|
|
8820
|
-
(at) => at.matchUpFormatCodes
|
|
8821
|
-
),
|
|
8822
|
-
...(extension.value.matchUpRecoveryTimes || []).map(
|
|
8823
|
-
(at) => at.matchUpFormatCodes
|
|
8824
|
-
)
|
|
8825
|
-
].flat()
|
|
8826
|
-
).map((matchUpFormat) => ({ matchUpFormat }));
|
|
8946
|
+
({ matchUpAverageTimes, matchUpRecoveryTimes } = extension.value);
|
|
8827
8947
|
} else {
|
|
8828
|
-
|
|
8948
|
+
({ matchUpAverageTimes, matchUpRecoveryTimes } = POLICY_SCHEDULING_DEFAULT[POLICY_TYPE_SCHEDULING]);
|
|
8829
8949
|
}
|
|
8950
|
+
matchUpFormatDefinitions = unique(
|
|
8951
|
+
[
|
|
8952
|
+
...(matchUpAverageTimes || []).map((at) => at.matchUpFormatCodes),
|
|
8953
|
+
...(matchUpRecoveryTimes || []).map((at) => at.matchUpFormatCodes)
|
|
8954
|
+
].flat()
|
|
8955
|
+
).map((matchUpFormat) => ({ matchUpFormat }));
|
|
8956
|
+
info = "default scheduling policy in use";
|
|
8830
8957
|
}
|
|
8831
8958
|
} else {
|
|
8832
8959
|
const uniqueMatchUpFormats = [];
|
|
@@ -8841,7 +8968,7 @@ function getEventMatchUpFormatTiming$1({
|
|
|
8841
8968
|
}).filter(Boolean);
|
|
8842
8969
|
}
|
|
8843
8970
|
const { eventType, eventId, category } = event;
|
|
8844
|
-
const categoryName = category?.categoryName
|
|
8971
|
+
const categoryName = category?.categoryName ?? category?.ageCategoryCode ?? eventId;
|
|
8845
8972
|
if (!eventId)
|
|
8846
8973
|
return { error: MISSING_EVENT };
|
|
8847
8974
|
const eventMatchUpFormatTiming = matchUpFormatDefinitions.map(
|
|
@@ -8854,17 +8981,14 @@ function getEventMatchUpFormatTiming$1({
|
|
|
8854
8981
|
eventType,
|
|
8855
8982
|
event
|
|
8856
8983
|
});
|
|
8857
|
-
return
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
matchUpFormat
|
|
8863
|
-
}
|
|
8864
|
-
);
|
|
8984
|
+
return {
|
|
8985
|
+
matchUpFormat,
|
|
8986
|
+
description,
|
|
8987
|
+
...timing
|
|
8988
|
+
};
|
|
8865
8989
|
}
|
|
8866
8990
|
);
|
|
8867
|
-
return { eventMatchUpFormatTiming };
|
|
8991
|
+
return definedAttributes({ eventMatchUpFormatTiming, info });
|
|
8868
8992
|
}
|
|
8869
8993
|
|
|
8870
8994
|
function getEventMatchUpFormatTiming({
|
|
@@ -9616,10 +9740,7 @@ function matchUpActions$2({
|
|
|
9616
9740
|
}
|
|
9617
9741
|
});
|
|
9618
9742
|
}
|
|
9619
|
-
if (
|
|
9620
|
-
// isInComplete && // TODO: determine whether removal should be disallowed for completed matchUps => policy consideration?
|
|
9621
|
-
existingParticipantIds?.length && (!scoreHasValue(matchUp) || side?.substitutions?.length)
|
|
9622
|
-
) {
|
|
9743
|
+
if (existingParticipantIds?.length && (!scoreHasValue(matchUp) || side?.substitutions?.length)) {
|
|
9623
9744
|
validActions.push({
|
|
9624
9745
|
method: REMOVE_TEAM_POSITION_METHOD,
|
|
9625
9746
|
type: REMOVE_PARTICIPANT,
|
|
@@ -11832,7 +11953,7 @@ function addStructureParticipation({
|
|
|
11832
11953
|
|
|
11833
11954
|
function processSides(params) {
|
|
11834
11955
|
const {
|
|
11835
|
-
|
|
11956
|
+
withScheduleItems,
|
|
11836
11957
|
scheduleAnalysis,
|
|
11837
11958
|
withTeamMatchUps,
|
|
11838
11959
|
participantMap,
|
|
@@ -11942,7 +12063,7 @@ function processSides(params) {
|
|
|
11942
12063
|
stage
|
|
11943
12064
|
});
|
|
11944
12065
|
}
|
|
11945
|
-
if (scheduleAnalysis ||
|
|
12066
|
+
if (scheduleAnalysis || withScheduleItems) {
|
|
11946
12067
|
addScheduleItem({
|
|
11947
12068
|
participantMap,
|
|
11948
12069
|
participantId: participantId2,
|
|
@@ -12088,6 +12209,7 @@ function getParticipantEntries(params) {
|
|
|
12088
12209
|
participantMap,
|
|
12089
12210
|
withPotentialMatchUps,
|
|
12090
12211
|
withRankingProfile,
|
|
12212
|
+
withScheduleItems,
|
|
12091
12213
|
scheduleAnalysis,
|
|
12092
12214
|
withTeamMatchUps,
|
|
12093
12215
|
withStatistics,
|
|
@@ -12097,7 +12219,6 @@ function getParticipantEntries(params) {
|
|
|
12097
12219
|
withEvents,
|
|
12098
12220
|
withDraws
|
|
12099
12221
|
} = params;
|
|
12100
|
-
const withScheduleTimes = params.withScheduleTimes ?? params.withScheduleItems;
|
|
12101
12222
|
const targetParticipantIds = participantFilters?.participantIds;
|
|
12102
12223
|
const getRelevantParticipantIds = (participantId) => {
|
|
12103
12224
|
const relevantParticipantIds = [participantId];
|
|
@@ -12115,7 +12236,7 @@ function getParticipantEntries(params) {
|
|
|
12115
12236
|
withDraws: withDraws || withRankingProfile,
|
|
12116
12237
|
withPotentialMatchUps,
|
|
12117
12238
|
withRankingProfile,
|
|
12118
|
-
|
|
12239
|
+
withScheduleItems,
|
|
12119
12240
|
scheduleAnalysis,
|
|
12120
12241
|
withTeamMatchUps,
|
|
12121
12242
|
withStatistics,
|
|
@@ -12435,7 +12556,7 @@ function getParticipantEntries(params) {
|
|
|
12435
12556
|
matchUpType: matchUpType2
|
|
12436
12557
|
});
|
|
12437
12558
|
}
|
|
12438
|
-
if (Array.isArray(potentialParticipants) && (nextMatchUps || !!scheduleAnalysis ||
|
|
12559
|
+
if (Array.isArray(potentialParticipants) && (nextMatchUps || !!scheduleAnalysis || withScheduleItems)) {
|
|
12439
12560
|
const potentialParticipantIds = potentialParticipants.flat().map(extractAttributes("participantId")).filter(Boolean);
|
|
12440
12561
|
potentialParticipantIds?.forEach((participantId) => {
|
|
12441
12562
|
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
@@ -12450,7 +12571,7 @@ function getParticipantEntries(params) {
|
|
|
12450
12571
|
drawId
|
|
12451
12572
|
});
|
|
12452
12573
|
});
|
|
12453
|
-
if (!!scheduleAnalysis ||
|
|
12574
|
+
if (!!scheduleAnalysis || withScheduleItems) {
|
|
12454
12575
|
addScheduleItem({
|
|
12455
12576
|
potential: true,
|
|
12456
12577
|
participantMap,
|
|
@@ -12559,13 +12680,18 @@ function getParticipantEntries(params) {
|
|
|
12559
12680
|
const notBeforeTime = typeChange ? typeChangeTimeAfterRecovery || timeAfterRecovery : timeAfterRecovery;
|
|
12560
12681
|
const sameDraw = scheduleItem.drawId === consideredItem.drawId;
|
|
12561
12682
|
const bothPotential = potentialMatchUps[scheduleItem.matchUpId] && potentialMatchUps[consideredItem.matchUpId];
|
|
12562
|
-
const
|
|
12563
|
-
|
|
12564
|
-
|
|
12565
|
-
|
|
12683
|
+
const consideredMinutes = timeStringMinutes(
|
|
12684
|
+
consideredItem.scheduledTime
|
|
12685
|
+
);
|
|
12686
|
+
const minutesDifference = Math.abs(
|
|
12687
|
+
consideredMinutes - scheduledMinutes
|
|
12688
|
+
);
|
|
12689
|
+
const itemIsPrior = consideredMinutes > scheduledMinutes;
|
|
12690
|
+
const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : itemIsPrior && timeStringMinutes(consideredItem.scheduledTime) < timeStringMinutes(notBeforeTime);
|
|
12691
|
+
if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
|
|
12566
12692
|
participantAggregator.scheduleConflicts.push({
|
|
12567
|
-
priorScheduledMatchUpId:
|
|
12568
|
-
matchUpIdWithConflict:
|
|
12693
|
+
priorScheduledMatchUpId: scheduleItem.matchUpId,
|
|
12694
|
+
matchUpIdWithConflict: consideredItem.matchUpId
|
|
12569
12695
|
});
|
|
12570
12696
|
}
|
|
12571
12697
|
}
|
|
@@ -12664,6 +12790,7 @@ function getParticipants(params) {
|
|
|
12664
12790
|
({
|
|
12665
12791
|
potentialMatchUps,
|
|
12666
12792
|
scheduleConflicts,
|
|
12793
|
+
scheduleItems,
|
|
12667
12794
|
participant,
|
|
12668
12795
|
statistics,
|
|
12669
12796
|
opponents,
|
|
@@ -12689,7 +12816,8 @@ function getParticipants(params) {
|
|
|
12689
12816
|
matchUps: withMatchUps || withRankingProfile ? Object.values(matchUps2) : void 0,
|
|
12690
12817
|
opponents: withOpponents ? participantOpponents : void 0,
|
|
12691
12818
|
potentialMatchUps: nextMatchUps ? Object.values(potentialMatchUps) : void 0,
|
|
12692
|
-
statistics: withStatistics ? Object.values(statistics) : void 0
|
|
12819
|
+
statistics: withStatistics ? Object.values(statistics) : void 0,
|
|
12820
|
+
scheduleItems: withScheduleItems ? scheduleItems : void 0
|
|
12693
12821
|
},
|
|
12694
12822
|
false,
|
|
12695
12823
|
false,
|
|
@@ -12720,1108 +12848,6 @@ function getParticipants(params) {
|
|
|
12720
12848
|
};
|
|
12721
12849
|
}
|
|
12722
12850
|
|
|
12723
|
-
function getDerivedPositionAssignments({
|
|
12724
|
-
derivedDrawInfo,
|
|
12725
|
-
participantId,
|
|
12726
|
-
drawId
|
|
12727
|
-
}) {
|
|
12728
|
-
const mainPositionAssignment = derivedDrawInfo[drawId]?.mainPositionAssignments?.find(
|
|
12729
|
-
(assignment) => assignment.participantId === participantId
|
|
12730
|
-
);
|
|
12731
|
-
const qualifyingPositionAssignment = derivedDrawInfo[drawId]?.qualifyingPositionAssignments?.find(
|
|
12732
|
-
(assignment) => assignment.participantId === participantId
|
|
12733
|
-
);
|
|
12734
|
-
const positionAssignments = {};
|
|
12735
|
-
if (mainPositionAssignment) {
|
|
12736
|
-
const { participantId: participantId2, ...props } = mainPositionAssignment;
|
|
12737
|
-
if (participantId2)
|
|
12738
|
-
positionAssignments[MAIN] = { ...props };
|
|
12739
|
-
}
|
|
12740
|
-
if (qualifyingPositionAssignment) {
|
|
12741
|
-
const { participantId: participantId2, ...props } = qualifyingPositionAssignment;
|
|
12742
|
-
if (participantId2)
|
|
12743
|
-
positionAssignments[QUALIFYING] = { ...props };
|
|
12744
|
-
}
|
|
12745
|
-
return Object.keys(positionAssignments).length ? positionAssignments : void 0;
|
|
12746
|
-
}
|
|
12747
|
-
|
|
12748
|
-
function getRelevantParticipantIdsMap({
|
|
12749
|
-
processParticipantId,
|
|
12750
|
-
// optional method which is passed each participantId
|
|
12751
|
-
tournamentRecords,
|
|
12752
|
-
tournamentRecord
|
|
12753
|
-
}) {
|
|
12754
|
-
if (typeof tournamentRecord !== "object" && typeof tournamentRecords !== "object")
|
|
12755
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
12756
|
-
const allParticipants = tournamentRecords ? Object.values(tournamentRecords).map((tournamentRecord2) => tournamentRecord2?.participants || []).flat() : tournamentRecord?.participants || [];
|
|
12757
|
-
const relevantParticipantIdsMap = Object.assign(
|
|
12758
|
-
{},
|
|
12759
|
-
...allParticipants.map(
|
|
12760
|
-
({ participantId, participantType, individualParticipantIds }) => {
|
|
12761
|
-
typeof processParticipantId === "function" && processParticipantId(participantId);
|
|
12762
|
-
const individualParticipantIdObjects = (individualParticipantIds || []).map((relevantParticipantId) => ({
|
|
12763
|
-
participantType: INDIVIDUAL,
|
|
12764
|
-
relevantParticipantId
|
|
12765
|
-
}));
|
|
12766
|
-
return {
|
|
12767
|
-
[participantId]: individualParticipantIdObjects.concat({
|
|
12768
|
-
relevantParticipantId: participantId,
|
|
12769
|
-
participantType
|
|
12770
|
-
})
|
|
12771
|
-
};
|
|
12772
|
-
}
|
|
12773
|
-
)
|
|
12774
|
-
);
|
|
12775
|
-
return { relevantParticipantIdsMap };
|
|
12776
|
-
}
|
|
12777
|
-
|
|
12778
|
-
function getDerivedSeedAssignments({
|
|
12779
|
-
derivedDrawInfo,
|
|
12780
|
-
participantId,
|
|
12781
|
-
drawId
|
|
12782
|
-
}) {
|
|
12783
|
-
const mainSeedAssignment = derivedDrawInfo[drawId]?.mainSeedAssignments?.find(
|
|
12784
|
-
(assignment) => assignment.participantId === participantId
|
|
12785
|
-
);
|
|
12786
|
-
const qualifyingSeedAssignment = derivedDrawInfo[drawId]?.qualifyingSeedAssignments?.find(
|
|
12787
|
-
(assignment) => assignment.participantId === participantId
|
|
12788
|
-
);
|
|
12789
|
-
const seedAssignments = {};
|
|
12790
|
-
if (mainSeedAssignment) {
|
|
12791
|
-
const { participantId: participantId2, ...props } = mainSeedAssignment;
|
|
12792
|
-
if (participantId2)
|
|
12793
|
-
seedAssignments[MAIN] = { ...props };
|
|
12794
|
-
}
|
|
12795
|
-
if (qualifyingSeedAssignment) {
|
|
12796
|
-
const { participantId: participantId2, ...props } = qualifyingSeedAssignment;
|
|
12797
|
-
if (participantId2)
|
|
12798
|
-
seedAssignments[QUALIFYING] = { ...props };
|
|
12799
|
-
}
|
|
12800
|
-
return Object.keys(seedAssignments).length ? seedAssignments : void 0;
|
|
12801
|
-
}
|
|
12802
|
-
|
|
12803
|
-
const hasSchedule = ({
|
|
12804
|
-
scheduleAttributes = ["scheduledDate", "scheduledTime"],
|
|
12805
|
-
schedule = {}
|
|
12806
|
-
}) => {
|
|
12807
|
-
const matchUpScheduleKeys = Object.keys(schedule).filter((key) => scheduleAttributes.includes(key)).filter((key) => schedule[key]);
|
|
12808
|
-
return !!matchUpScheduleKeys.length;
|
|
12809
|
-
};
|
|
12810
|
-
|
|
12811
|
-
function participantScheduledMatchUps({
|
|
12812
|
-
scheduleAttributes = ["scheduledDate", "scheduledTime"],
|
|
12813
|
-
matchUps = []
|
|
12814
|
-
}) {
|
|
12815
|
-
if (!validMatchUps(matchUps))
|
|
12816
|
-
return { error: MISSING_MATCHUPS };
|
|
12817
|
-
if (!Array.isArray(scheduleAttributes))
|
|
12818
|
-
return { error: INVALID_VALUES };
|
|
12819
|
-
const scheduledMatchUps = matchUps.filter(Boolean).filter(({ schedule }) => hasSchedule({ schedule, scheduleAttributes })).reduce((dateMatchUps, matchUp) => {
|
|
12820
|
-
const { schedule } = matchUp;
|
|
12821
|
-
const date = extractDate(schedule?.scheduledDate);
|
|
12822
|
-
const time = extractTime(schedule?.scheduledTime);
|
|
12823
|
-
if (date && time) {
|
|
12824
|
-
if (dateMatchUps[date]) {
|
|
12825
|
-
dateMatchUps[date].push(matchUp);
|
|
12826
|
-
} else {
|
|
12827
|
-
dateMatchUps[date] = [matchUp];
|
|
12828
|
-
}
|
|
12829
|
-
}
|
|
12830
|
-
return dateMatchUps;
|
|
12831
|
-
}, {});
|
|
12832
|
-
const dates = Object.keys(scheduledMatchUps);
|
|
12833
|
-
dates.forEach((date) => {
|
|
12834
|
-
scheduledMatchUps[date].sort(
|
|
12835
|
-
(a, b) => timeSort(
|
|
12836
|
-
extractTime(a.schedule?.scheduledTime),
|
|
12837
|
-
extractTime(b.schedule?.scheduledTime)
|
|
12838
|
-
)
|
|
12839
|
-
);
|
|
12840
|
-
});
|
|
12841
|
-
return { scheduledMatchUps };
|
|
12842
|
-
}
|
|
12843
|
-
|
|
12844
|
-
function annotateParticipant(params) {
|
|
12845
|
-
const {
|
|
12846
|
-
withScaleValues = true,
|
|
12847
|
-
eventsPublishStatuses,
|
|
12848
|
-
withEvents = true,
|
|
12849
|
-
withDraws = true,
|
|
12850
|
-
participantIdMap,
|
|
12851
|
-
scheduleAnalysis,
|
|
12852
|
-
derivedDrawInfo,
|
|
12853
|
-
usePublishState,
|
|
12854
|
-
withStatistics,
|
|
12855
|
-
withOpponents,
|
|
12856
|
-
withMatchUps,
|
|
12857
|
-
withSeeding,
|
|
12858
|
-
participant,
|
|
12859
|
-
withISO2,
|
|
12860
|
-
withIOC
|
|
12861
|
-
} = params;
|
|
12862
|
-
const scheduleConflicts = [];
|
|
12863
|
-
const scheduleItems = [];
|
|
12864
|
-
if (withIOC || withISO2)
|
|
12865
|
-
addNationalityCode({ participant, withIOC, withISO2 });
|
|
12866
|
-
if (withScaleValues) {
|
|
12867
|
-
const { ratings, rankings } = getScaleValues({ participant });
|
|
12868
|
-
participant.rankings = rankings;
|
|
12869
|
-
participant.ratings = ratings;
|
|
12870
|
-
}
|
|
12871
|
-
const participantId = participant?.participantId;
|
|
12872
|
-
if (!participantId || !participantIdMap[participantId])
|
|
12873
|
-
return {};
|
|
12874
|
-
const {
|
|
12875
|
-
potentialMatchUps,
|
|
12876
|
-
opponents,
|
|
12877
|
-
matchUps,
|
|
12878
|
-
events,
|
|
12879
|
-
losses,
|
|
12880
|
-
draws,
|
|
12881
|
-
wins
|
|
12882
|
-
} = participantIdMap[participantId];
|
|
12883
|
-
const denominator = wins + losses;
|
|
12884
|
-
const numerator = wins;
|
|
12885
|
-
const statValue = denominator && numerator / denominator;
|
|
12886
|
-
const winRatioStat = {
|
|
12887
|
-
statCode: WIN_RATIO,
|
|
12888
|
-
denominator,
|
|
12889
|
-
numerator,
|
|
12890
|
-
statValue
|
|
12891
|
-
};
|
|
12892
|
-
const participantDraws = Object.values(draws);
|
|
12893
|
-
const participantEvents = Object.values(events);
|
|
12894
|
-
if (withDraws && participantDraws) {
|
|
12895
|
-
participant.draws = participantDraws;
|
|
12896
|
-
for (const participantDraw of participantDraws) {
|
|
12897
|
-
const publishedSeeding = eventsPublishStatuses[participantDraw.eventId]?.publishedSeeding;
|
|
12898
|
-
const seedingPublished = !usePublishState || publishedSeeding?.published && (publishedSeeding?.drawIds?.length === 0 || publishedSeeding?.drawIds?.includes(participantDraw.drawId));
|
|
12899
|
-
if (seedingPublished) {
|
|
12900
|
-
const seedAssignments = getDerivedSeedAssignments({
|
|
12901
|
-
drawId: participantDraw.drawId,
|
|
12902
|
-
derivedDrawInfo,
|
|
12903
|
-
participantId
|
|
12904
|
-
});
|
|
12905
|
-
if (seedAssignments) {
|
|
12906
|
-
participantDraw.seedAssignments = seedAssignments;
|
|
12907
|
-
}
|
|
12908
|
-
}
|
|
12909
|
-
}
|
|
12910
|
-
}
|
|
12911
|
-
if (withEvents && participantEvents) {
|
|
12912
|
-
participant.events = participantEvents;
|
|
12913
|
-
if (withSeeding) {
|
|
12914
|
-
const seedingScales = Object.assign(
|
|
12915
|
-
{},
|
|
12916
|
-
...(participant.timeItems || []).filter(({ itemType }) => itemType.split(".")[1] === SEEDING).map(({ itemType: seedingScaleName, itemValue: seedValue }) => ({
|
|
12917
|
-
[seedingScaleName]: seedValue
|
|
12918
|
-
}))
|
|
12919
|
-
);
|
|
12920
|
-
for (const participantEvent of participantEvents) {
|
|
12921
|
-
const getScaleAccessor = (scaleName) => [SCALE, SEEDING, participantEvent.eventType, scaleName].join(".");
|
|
12922
|
-
const publishedSeeding = eventsPublishStatuses[participantEvent.eventId]?.publishedSeeding;
|
|
12923
|
-
const eventSeedingScaleNames = (publishedSeeding?.stageSeedingScaleNames && Object.values(publishedSeeding?.stageSeedingScaleNames) || Array.isArray(publishedSeeding?.seedingScaleNames) && publishedSeeding.seedingScaleNames || []).map(getScaleAccessor);
|
|
12924
|
-
const publishedEventSeedingScaleNames = intersection(
|
|
12925
|
-
Object.keys(seedingScales),
|
|
12926
|
-
eventSeedingScaleNames
|
|
12927
|
-
);
|
|
12928
|
-
const eventSeedingPublished = !!(!usePublishState || !Object.keys(seedingScales).length && !publishedSeeding?.drawIds?.length || publishedEventSeedingScaleNames.length);
|
|
12929
|
-
if (eventSeedingPublished && publishedEventSeedingScaleNames.length) {
|
|
12930
|
-
if (publishedSeeding?.stageSeedingScaleNames) {
|
|
12931
|
-
const scaleValues = Object.keys(
|
|
12932
|
-
publishedSeeding.stageSeedingScaleNames
|
|
12933
|
-
).map((key) => {
|
|
12934
|
-
const accessor = getScaleAccessor(
|
|
12935
|
-
publishedSeeding.stageSeedingScaleNames[key]
|
|
12936
|
-
);
|
|
12937
|
-
const scaleValue = seedingScales[accessor];
|
|
12938
|
-
return [key, scaleValue];
|
|
12939
|
-
}).filter((pair) => pair[1]).map((pair) => ({ [pair[0]]: { seedValue: pair[1] } }));
|
|
12940
|
-
const seedAssignments = Object.assign({}, ...scaleValues);
|
|
12941
|
-
participantEvent.seedAssignments = seedAssignments;
|
|
12942
|
-
} else if (publishedEventSeedingScaleNames) {
|
|
12943
|
-
const seedValues = publishedEventSeedingScaleNames.map(
|
|
12944
|
-
(scaleName) => seedingScales[scaleName]
|
|
12945
|
-
);
|
|
12946
|
-
participantEvent.seedValue = seedValues.pop();
|
|
12947
|
-
}
|
|
12948
|
-
} else if (!usePublishState && typeof withSeeding === "object") {
|
|
12949
|
-
const scaleValues = Object.keys(withSeeding).map((key) => {
|
|
12950
|
-
const accessor = getScaleAccessor(withSeeding[key]);
|
|
12951
|
-
const scaleValue = seedingScales[accessor];
|
|
12952
|
-
return [key, scaleValue];
|
|
12953
|
-
}).filter((pair) => pair[1]).map((pair) => ({ [pair[0]]: { seedValue: pair[1] } }));
|
|
12954
|
-
const seedAssignments = Object.assign({}, ...scaleValues);
|
|
12955
|
-
participantEvent.seedAssignments = seedAssignments;
|
|
12956
|
-
} else {
|
|
12957
|
-
const { categoryName, ageCategoryCode } = participantEvent.category || {};
|
|
12958
|
-
let scaleItem;
|
|
12959
|
-
for (const scaleName of [
|
|
12960
|
-
participantEvent.eventId,
|
|
12961
|
-
ageCategoryCode,
|
|
12962
|
-
categoryName
|
|
12963
|
-
]) {
|
|
12964
|
-
const scaleAttributes = {
|
|
12965
|
-
eventType: participantEvent.eventType,
|
|
12966
|
-
scaleType: SEEDING,
|
|
12967
|
-
scaleName
|
|
12968
|
-
};
|
|
12969
|
-
const result = participantScaleItem({
|
|
12970
|
-
scaleAttributes,
|
|
12971
|
-
participant
|
|
12972
|
-
});
|
|
12973
|
-
if (result.scaleItem) {
|
|
12974
|
-
scaleItem = result.scaleItem;
|
|
12975
|
-
break;
|
|
12976
|
-
}
|
|
12977
|
-
}
|
|
12978
|
-
if (scaleItem) {
|
|
12979
|
-
const seedValue = scaleItem.scaleValue;
|
|
12980
|
-
const seedingPublished = !usePublishState || publishedSeeding?.published && (publishedSeeding?.drawIds?.length === 0 || publishedSeeding?.drawIds?.includes(
|
|
12981
|
-
participantEvent.drawId
|
|
12982
|
-
));
|
|
12983
|
-
if (seedingPublished) {
|
|
12984
|
-
participantEvent.seedValue = seedValue;
|
|
12985
|
-
}
|
|
12986
|
-
}
|
|
12987
|
-
}
|
|
12988
|
-
if (participantEvent.drawIds?.length) {
|
|
12989
|
-
for (const flightDrawId of participantEvent.drawIds || []) {
|
|
12990
|
-
const drawSeedPublishingDisabled = publishedSeeding?.drawIds?.length && !publishedSeeding?.drawIds?.includes(flightDrawId);
|
|
12991
|
-
if (eventSeedingPublished && !drawSeedPublishingDisabled) {
|
|
12992
|
-
const seedAssignments = getDerivedSeedAssignments({
|
|
12993
|
-
drawId: flightDrawId,
|
|
12994
|
-
derivedDrawInfo,
|
|
12995
|
-
participantId
|
|
12996
|
-
});
|
|
12997
|
-
if (seedAssignments && participantEvent.seedAssignments) {
|
|
12998
|
-
for (const key of Object.keys(
|
|
12999
|
-
participantEvent.seedAssignments
|
|
13000
|
-
)) {
|
|
13001
|
-
participantEvent.seedAssignments[key] = seedAssignments[key];
|
|
13002
|
-
}
|
|
13003
|
-
} else {
|
|
13004
|
-
participantEvent.seedAssignments = seedAssignments;
|
|
13005
|
-
}
|
|
13006
|
-
}
|
|
13007
|
-
}
|
|
13008
|
-
}
|
|
13009
|
-
}
|
|
13010
|
-
}
|
|
13011
|
-
}
|
|
13012
|
-
const participantOpponents = Object.values(opponents).flat();
|
|
13013
|
-
if (withOpponents && participantOpponents?.length) {
|
|
13014
|
-
participant.opponents = participantOpponents;
|
|
13015
|
-
participantDraws?.forEach((draw) => {
|
|
13016
|
-
draw.opponents = participantOpponents.filter(
|
|
13017
|
-
(opponent) => opponent.drawId === draw.drawId
|
|
13018
|
-
);
|
|
13019
|
-
});
|
|
13020
|
-
}
|
|
13021
|
-
const participantPotentialMatchUps = Object.values(potentialMatchUps);
|
|
13022
|
-
const participantMatchUps = Object.values(matchUps);
|
|
13023
|
-
if (withMatchUps) {
|
|
13024
|
-
participant.potentialMatchUps = participantPotentialMatchUps;
|
|
13025
|
-
participant.matchUps = participantMatchUps;
|
|
13026
|
-
}
|
|
13027
|
-
const allParticipantMatchUps = participantMatchUps.concat(
|
|
13028
|
-
participantPotentialMatchUps
|
|
13029
|
-
);
|
|
13030
|
-
const scheduledMatchUps = participantScheduledMatchUps({
|
|
13031
|
-
matchUps: allParticipantMatchUps
|
|
13032
|
-
})?.scheduledMatchUps || [];
|
|
13033
|
-
const { scheduledMinutesDifference } = scheduleAnalysis || {};
|
|
13034
|
-
const dates = Object.keys(scheduledMatchUps);
|
|
13035
|
-
dates.forEach((date) => {
|
|
13036
|
-
scheduledMatchUps[date].filter(Boolean).forEach((matchUp, i) => {
|
|
13037
|
-
const {
|
|
13038
|
-
schedule: {
|
|
13039
|
-
scheduledTime,
|
|
13040
|
-
timeAfterRecovery,
|
|
13041
|
-
typeChangeTimeAfterRecovery
|
|
13042
|
-
},
|
|
13043
|
-
matchUpStatus,
|
|
13044
|
-
roundPosition,
|
|
13045
|
-
structureName,
|
|
13046
|
-
matchUpType,
|
|
13047
|
-
roundNumber,
|
|
13048
|
-
matchUpId,
|
|
13049
|
-
drawId,
|
|
13050
|
-
score
|
|
13051
|
-
} = matchUp;
|
|
13052
|
-
scheduleItems.push({
|
|
13053
|
-
...matchUp.schedule,
|
|
13054
|
-
scheduledTime: extractTime(matchUp.schedule?.scheduledTime),
|
|
13055
|
-
roundPosition,
|
|
13056
|
-
structureName,
|
|
13057
|
-
matchUpType,
|
|
13058
|
-
roundNumber,
|
|
13059
|
-
matchUpId,
|
|
13060
|
-
drawId
|
|
13061
|
-
});
|
|
13062
|
-
const ignoreMatchUp = matchUpStatus === BYE || [WALKOVER$1, DEFAULTED].includes(matchUpStatus) && !scoreHasValue({ score });
|
|
13063
|
-
if (scheduledTime && !ignoreMatchUp) {
|
|
13064
|
-
const scheduledMinutes = timeStringMinutes(scheduledTime);
|
|
13065
|
-
const matchUpsToConsider = scheduledMatchUps[date].slice(i + 1);
|
|
13066
|
-
for (const consideredMatchUp of matchUpsToConsider) {
|
|
13067
|
-
const ignoreMatchUp2 = consideredMatchUp.matchUpStatus === BYE || [WALKOVER$1, DEFAULTED].includes(consideredMatchUp.matchUpStatus) && !scoreHasValue(consideredMatchUp);
|
|
13068
|
-
if (!ignoreMatchUp2 && consideredMatchUp.schedule?.scheduledTime) {
|
|
13069
|
-
const typeChange = matchUp.matchUpType !== consideredMatchUp.matchUpType;
|
|
13070
|
-
const notBeforeTime = typeChange ? typeChangeTimeAfterRecovery || timeAfterRecovery : timeAfterRecovery;
|
|
13071
|
-
const sameDraw = matchUp.drawId === consideredMatchUp.drawId;
|
|
13072
|
-
const bothPotential = matchUp.potential && consideredMatchUp.potential;
|
|
13073
|
-
const nextMinutes = timeStringMinutes(
|
|
13074
|
-
consideredMatchUp.schedule?.scheduledTime
|
|
13075
|
-
);
|
|
13076
|
-
const minutesDifference = nextMinutes - scheduledMinutes;
|
|
13077
|
-
const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : timeStringMinutes(notBeforeTime) > timeStringMinutes(consideredMatchUp.schedule?.scheduledTime);
|
|
13078
|
-
if (timeOverlap && !(bothPotential && sameDraw)) {
|
|
13079
|
-
scheduleConflicts.push({
|
|
13080
|
-
priorScheduledMatchUpId: consideredMatchUp.matchUpId,
|
|
13081
|
-
matchUpIdWithConflict: matchUpId
|
|
13082
|
-
});
|
|
13083
|
-
}
|
|
13084
|
-
}
|
|
13085
|
-
}
|
|
13086
|
-
}
|
|
13087
|
-
});
|
|
13088
|
-
});
|
|
13089
|
-
if (withStatistics)
|
|
13090
|
-
participant.statistics = [winRatioStat];
|
|
13091
|
-
return { scheduleConflicts, scheduleItems };
|
|
13092
|
-
}
|
|
13093
|
-
|
|
13094
|
-
function getDrawDetails({
|
|
13095
|
-
eventEntries,
|
|
13096
|
-
sortConfig,
|
|
13097
|
-
event
|
|
13098
|
-
}) {
|
|
13099
|
-
const derivedInfo = {};
|
|
13100
|
-
const drawDetails = Object.assign(
|
|
13101
|
-
{},
|
|
13102
|
-
...(event.drawDefinitions ?? []).map((drawDefinition) => {
|
|
13103
|
-
const entriesMap = Object.assign(
|
|
13104
|
-
{},
|
|
13105
|
-
...(eventEntries ?? []).filter((entry) => entry.participantId).map((entry) => ({ [entry.participantId]: entry })),
|
|
13106
|
-
...drawDefinition.entries.filter((entry) => entry.participantId).map((entry) => ({ [entry.participantId]: entry }))
|
|
13107
|
-
);
|
|
13108
|
-
const drawEntries = Object.values(entriesMap);
|
|
13109
|
-
const mainStructure = getDrawStructures({
|
|
13110
|
-
stageSequence: 1,
|
|
13111
|
-
drawDefinition,
|
|
13112
|
-
stage: MAIN
|
|
13113
|
-
})?.structures?.[0];
|
|
13114
|
-
const mainPositionAssignments = mainStructure && getPositionAssignments({
|
|
13115
|
-
structure: mainStructure
|
|
13116
|
-
})?.positionAssignments;
|
|
13117
|
-
const drawSize = mainPositionAssignments?.length;
|
|
13118
|
-
const qualifyingStructure = getDrawStructures({
|
|
13119
|
-
stageSequence: 1,
|
|
13120
|
-
stage: QUALIFYING,
|
|
13121
|
-
drawDefinition
|
|
13122
|
-
})?.structures?.[0];
|
|
13123
|
-
const qualifyingPositionAssignments = mainStructure && getPositionAssignments({
|
|
13124
|
-
structure: qualifyingStructure
|
|
13125
|
-
})?.positionAssignments;
|
|
13126
|
-
const qualifyingDrawSize = qualifyingPositionAssignments?.length;
|
|
13127
|
-
const mainSeedAssignments = mainStructure?.seedAssignments;
|
|
13128
|
-
const qualifyingSeedAssignments = qualifyingStructure?.seedAssignments;
|
|
13129
|
-
const orderedStructureIds = (drawDefinition.structures || []).sort((a, b) => structureSort(a, b, sortConfig)).map(({ structureId, structures }) => {
|
|
13130
|
-
return [
|
|
13131
|
-
structureId,
|
|
13132
|
-
...(structures || []).map(({ structureId: structureId2 }) => structureId2)
|
|
13133
|
-
];
|
|
13134
|
-
}).flat(Infinity);
|
|
13135
|
-
const flightNumber = event?._flightProfile?.flights?.find(
|
|
13136
|
-
(flight) => flight.drawId === drawDefinition.drawId
|
|
13137
|
-
)?.flightNumber;
|
|
13138
|
-
derivedInfo[drawDefinition.drawId] = {
|
|
13139
|
-
qualifyingPositionAssignments,
|
|
13140
|
-
qualifyingSeedAssignments,
|
|
13141
|
-
mainPositionAssignments,
|
|
13142
|
-
mainSeedAssignments,
|
|
13143
|
-
orderedStructureIds,
|
|
13144
|
-
qualifyingDrawSize,
|
|
13145
|
-
flightNumber,
|
|
13146
|
-
drawSize
|
|
13147
|
-
};
|
|
13148
|
-
return {
|
|
13149
|
-
[drawDefinition.drawId]: {
|
|
13150
|
-
drawType: drawDefinition.drawType,
|
|
13151
|
-
drawEntries
|
|
13152
|
-
}
|
|
13153
|
-
};
|
|
13154
|
-
})
|
|
13155
|
-
);
|
|
13156
|
-
return { derivedInfo, drawDetails };
|
|
13157
|
-
}
|
|
13158
|
-
|
|
13159
|
-
function processMatchUp({
|
|
13160
|
-
relevantParticipantIdsMap,
|
|
13161
|
-
participantFilters,
|
|
13162
|
-
participantIdMap,
|
|
13163
|
-
derivedDrawInfo,
|
|
13164
|
-
eventDrawsCount,
|
|
13165
|
-
drawDetails,
|
|
13166
|
-
eventType,
|
|
13167
|
-
matchUp
|
|
13168
|
-
}) {
|
|
13169
|
-
const {
|
|
13170
|
-
collectionId,
|
|
13171
|
-
collectionPosition,
|
|
13172
|
-
drawId,
|
|
13173
|
-
drawName,
|
|
13174
|
-
eventId,
|
|
13175
|
-
eventName,
|
|
13176
|
-
finishingRound,
|
|
13177
|
-
finishingPositionRange,
|
|
13178
|
-
processCodes,
|
|
13179
|
-
loserTo,
|
|
13180
|
-
matchUpId,
|
|
13181
|
-
matchUpType,
|
|
13182
|
-
matchUpFormat,
|
|
13183
|
-
matchUpStatus,
|
|
13184
|
-
matchUpStatusCodes,
|
|
13185
|
-
matchUpTieId,
|
|
13186
|
-
roundName,
|
|
13187
|
-
roundNumber,
|
|
13188
|
-
roundPosition,
|
|
13189
|
-
score,
|
|
13190
|
-
sides,
|
|
13191
|
-
stage,
|
|
13192
|
-
stageSequence,
|
|
13193
|
-
schedule,
|
|
13194
|
-
structureName,
|
|
13195
|
-
structureId,
|
|
13196
|
-
tieFormat,
|
|
13197
|
-
tieMatchUps,
|
|
13198
|
-
tournamentId,
|
|
13199
|
-
winnerTo,
|
|
13200
|
-
winningSide
|
|
13201
|
-
} = matchUp;
|
|
13202
|
-
const targetParticipantIds = participantFilters?.participantIds;
|
|
13203
|
-
const getRelevantParticipantIds = (participantId) => {
|
|
13204
|
-
const relevantParticipantIds = participantId && relevantParticipantIdsMap[participantId] || [];
|
|
13205
|
-
relevantParticipantIds.push(participantId);
|
|
13206
|
-
return relevantParticipantIds.some(
|
|
13207
|
-
(obj) => !targetParticipantIds || targetParticipantIds.includes(obj.relevantParticipantId)
|
|
13208
|
-
) ? relevantParticipantIds : [];
|
|
13209
|
-
};
|
|
13210
|
-
const { winner, loser } = finishingPositionRange || {};
|
|
13211
|
-
const doublesTieParticipants = tieMatchUps?.length && tieMatchUps.filter(({ matchUpType: matchUpType2 }) => matchUpType2 === DOUBLES_MATCHUP).map(
|
|
13212
|
-
({ sides: sides2 }) => sides2.map(
|
|
13213
|
-
({ sideNumber, participantId, participant }) => sideNumber && participantId && {
|
|
13214
|
-
sideNumber,
|
|
13215
|
-
participantId,
|
|
13216
|
-
participant
|
|
13217
|
-
}
|
|
13218
|
-
)
|
|
13219
|
-
).flat().filter(Boolean) || [];
|
|
13220
|
-
if (eventType === TEAM_EVENT && matchUpType === DOUBLES_MATCHUP) {
|
|
13221
|
-
const participants = (matchUp.sides?.filter(Boolean) || []).map(
|
|
13222
|
-
({ sideNumber, participantId, participant }) => sideNumber && participantId && {
|
|
13223
|
-
sideNumber,
|
|
13224
|
-
participantId,
|
|
13225
|
-
participant
|
|
13226
|
-
}
|
|
13227
|
-
).filter(Boolean);
|
|
13228
|
-
doublesTieParticipants.push(...participants);
|
|
13229
|
-
}
|
|
13230
|
-
sides?.forEach((params) => {
|
|
13231
|
-
const { participantId, sideNumber } = params;
|
|
13232
|
-
if (!participantId)
|
|
13233
|
-
return;
|
|
13234
|
-
const { drawType, drawEntries } = drawDetails[drawId];
|
|
13235
|
-
const participantScore = sideNumber === 1 ? score?.scoreStringSide1 : score?.scoreStringSide2;
|
|
13236
|
-
const participantWon = winningSide && sideNumber === winningSide;
|
|
13237
|
-
const opponent = matchUp.sides.find(
|
|
13238
|
-
(side) => side.sideNumber === 3 - sideNumber
|
|
13239
|
-
);
|
|
13240
|
-
const opponentParticipantId = opponent?.participantId;
|
|
13241
|
-
const relevantOpponents = opponentParticipantId && relevantParticipantIdsMap[opponentParticipantId] || [];
|
|
13242
|
-
const finishingPositionRange2 = participantWon ? winner : loser;
|
|
13243
|
-
const drawEntry = drawEntries.find(
|
|
13244
|
-
(entry) => entry.participantId === participantId
|
|
13245
|
-
);
|
|
13246
|
-
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
13247
|
-
const addedPairParticipantIds = [];
|
|
13248
|
-
doublesTieParticipants?.filter((participant) => participant.sideNumber === sideNumber).forEach((p) => {
|
|
13249
|
-
const participantId2 = p.participantId;
|
|
13250
|
-
if (participantId2 && !addedPairParticipantIds.includes(participantId2)) {
|
|
13251
|
-
relevantParticipantIds.push({
|
|
13252
|
-
relevantParticipantId: participantId2,
|
|
13253
|
-
participantType: PAIR
|
|
13254
|
-
});
|
|
13255
|
-
addedPairParticipantIds.push(participantId2);
|
|
13256
|
-
}
|
|
13257
|
-
});
|
|
13258
|
-
const filteredRelevantParticipantIds = relevantParticipantIds.filter(
|
|
13259
|
-
(opponent2) => {
|
|
13260
|
-
return eventType !== TEAM_EVENT || eventType === TEAM_EVENT && [DOUBLES_MATCHUP, TEAM_MATCHUP].includes(matchUpType) && [PAIR, TEAM_PARTICIPANT].includes(opponent2.participantType) || eventType === TEAM_EVENT && [SINGLES_MATCHUP, DOUBLES_MATCHUP].includes(matchUpType) && [INDIVIDUAL].includes(opponent2.participantType);
|
|
13261
|
-
}
|
|
13262
|
-
);
|
|
13263
|
-
filteredRelevantParticipantIds?.forEach(
|
|
13264
|
-
({ relevantParticipantId, participantType }) => {
|
|
13265
|
-
const { entryStage, entryStatus, entryPosition } = drawEntry || {};
|
|
13266
|
-
if (!participantIdMap[relevantParticipantId])
|
|
13267
|
-
return;
|
|
13268
|
-
if (!participantIdMap[relevantParticipantId].draws[drawId]) {
|
|
13269
|
-
const positionAssignments = getDerivedPositionAssignments({
|
|
13270
|
-
participantId: relevantParticipantId,
|
|
13271
|
-
derivedDrawInfo,
|
|
13272
|
-
drawId
|
|
13273
|
-
});
|
|
13274
|
-
const seedAssignments = getDerivedSeedAssignments({
|
|
13275
|
-
participantId: relevantParticipantId,
|
|
13276
|
-
derivedDrawInfo,
|
|
13277
|
-
drawId
|
|
13278
|
-
});
|
|
13279
|
-
participantIdMap[relevantParticipantId].draws[drawId] = definedAttributes({
|
|
13280
|
-
qualifyingDrawSize: derivedDrawInfo[drawId]?.qualifyingDrawSize,
|
|
13281
|
-
drawSize: derivedDrawInfo[drawId]?.drawSize,
|
|
13282
|
-
partnerParticipantIds: [],
|
|
13283
|
-
positionAssignments,
|
|
13284
|
-
seedAssignments,
|
|
13285
|
-
entryPosition,
|
|
13286
|
-
entryStatus,
|
|
13287
|
-
entryStage,
|
|
13288
|
-
drawName,
|
|
13289
|
-
drawType,
|
|
13290
|
-
eventId,
|
|
13291
|
-
drawId
|
|
13292
|
-
});
|
|
13293
|
-
}
|
|
13294
|
-
if (!participantIdMap[relevantParticipantId].events[eventId]) {
|
|
13295
|
-
participantIdMap[relevantParticipantId].events[eventId] = {
|
|
13296
|
-
partnerParticipantIds: [],
|
|
13297
|
-
drawIds: [],
|
|
13298
|
-
eventName,
|
|
13299
|
-
eventId
|
|
13300
|
-
};
|
|
13301
|
-
}
|
|
13302
|
-
const eventDrawIds = participantIdMap[relevantParticipantId].events[eventId].drawIds;
|
|
13303
|
-
if (eventDrawIds && !eventDrawIds?.includes(drawId)) {
|
|
13304
|
-
participantIdMap[relevantParticipantId].events[eventId].drawIds.push(
|
|
13305
|
-
drawId
|
|
13306
|
-
);
|
|
13307
|
-
}
|
|
13308
|
-
let partnerParticipantId;
|
|
13309
|
-
if (participantType === INDIVIDUAL && matchUpType === DOUBLES_MATCHUP) {
|
|
13310
|
-
const relevantParticipantInfo = filteredRelevantParticipantIds.find(
|
|
13311
|
-
(participantInfo) => {
|
|
13312
|
-
return participantInfo.relevantParticipantId !== relevantParticipantId && participantInfo.participantType === INDIVIDUAL;
|
|
13313
|
-
}
|
|
13314
|
-
);
|
|
13315
|
-
partnerParticipantId = relevantParticipantInfo?.relevantParticipantId;
|
|
13316
|
-
}
|
|
13317
|
-
const filteredRelevantOpponents = relevantOpponents?.filter(
|
|
13318
|
-
(opponent2) => matchUpType === TEAM_MATCHUP && participantType === TEAM_PARTICIPANT && opponent2.participantType === TEAM_PARTICIPANT || matchUpType === SINGLES_MATCHUP && opponent2.participantType === INDIVIDUAL || matchUpType === DOUBLES_MATCHUP && (participantType === INDIVIDUAL ? [INDIVIDUAL, PAIR].includes(opponent2.participantType) : (
|
|
13319
|
-
// for PAIR participants only show PAIR opponenents
|
|
13320
|
-
opponent2.participantType === PAIR
|
|
13321
|
-
))
|
|
13322
|
-
) || [];
|
|
13323
|
-
filteredRelevantOpponents.forEach(
|
|
13324
|
-
({
|
|
13325
|
-
relevantParticipantId: opponentParticipantId2,
|
|
13326
|
-
participantType: opponentParticipantType
|
|
13327
|
-
}) => {
|
|
13328
|
-
if (!participantIdMap[relevantParticipantId].opponents) {
|
|
13329
|
-
participantIdMap[relevantParticipantId].opponents = {};
|
|
13330
|
-
}
|
|
13331
|
-
participantIdMap[relevantParticipantId].opponents[opponentParticipantId2] = {
|
|
13332
|
-
eventId,
|
|
13333
|
-
drawId,
|
|
13334
|
-
matchUpId,
|
|
13335
|
-
participantType: opponentParticipantType,
|
|
13336
|
-
participantId: opponentParticipantId2
|
|
13337
|
-
};
|
|
13338
|
-
}
|
|
13339
|
-
);
|
|
13340
|
-
const opponentParticipantInfo = filteredRelevantOpponents.map(
|
|
13341
|
-
({ relevantParticipantId: relevantParticipantId2, participantType: participantType2 }) => ({
|
|
13342
|
-
participantId: relevantParticipantId2,
|
|
13343
|
-
participantType: participantType2
|
|
13344
|
-
})
|
|
13345
|
-
);
|
|
13346
|
-
const includeMatchUp = matchUpType !== TEAM_MATCHUP && [INDIVIDUAL, PAIR].includes(participantType) || matchUpType === TEAM_MATCHUP && participantType === TEAM_PARTICIPANT;
|
|
13347
|
-
if (includeMatchUp)
|
|
13348
|
-
participantIdMap[relevantParticipantId].matchUps[matchUpId] = definedAttributes({
|
|
13349
|
-
collectionId,
|
|
13350
|
-
collectionPosition,
|
|
13351
|
-
drawId,
|
|
13352
|
-
eventId,
|
|
13353
|
-
eventType,
|
|
13354
|
-
eventDrawsCount,
|
|
13355
|
-
finishingRound,
|
|
13356
|
-
finishingPositionRange: finishingPositionRange2,
|
|
13357
|
-
loserTo,
|
|
13358
|
-
matchUpId,
|
|
13359
|
-
matchUpType,
|
|
13360
|
-
matchUpFormat,
|
|
13361
|
-
matchUpStatus,
|
|
13362
|
-
matchUpStatusCodes,
|
|
13363
|
-
matchUpTieId,
|
|
13364
|
-
opponentParticipantInfo,
|
|
13365
|
-
participantWon,
|
|
13366
|
-
partnerParticipantId,
|
|
13367
|
-
perspectiveScoreString: participantScore,
|
|
13368
|
-
processCodes,
|
|
13369
|
-
roundName,
|
|
13370
|
-
roundNumber,
|
|
13371
|
-
roundPosition,
|
|
13372
|
-
schedule,
|
|
13373
|
-
score,
|
|
13374
|
-
sides,
|
|
13375
|
-
stage,
|
|
13376
|
-
stageSequence,
|
|
13377
|
-
structureName,
|
|
13378
|
-
structureId,
|
|
13379
|
-
tieFormat,
|
|
13380
|
-
tournamentId,
|
|
13381
|
-
winnerTo,
|
|
13382
|
-
winningSide
|
|
13383
|
-
});
|
|
13384
|
-
if (partnerParticipantId) {
|
|
13385
|
-
participantIdMap[relevantParticipantId].events[eventId].partnerParticipantIds.push(partnerParticipantId);
|
|
13386
|
-
participantIdMap[relevantParticipantId].draws[drawId].partnerParticipantIds.push(partnerParticipantId);
|
|
13387
|
-
participantIdMap[relevantParticipantId].events[eventId].partnerParticipantId = partnerParticipantId;
|
|
13388
|
-
participantIdMap[relevantParticipantId].draws[drawId].partnerParticipantId = partnerParticipantId;
|
|
13389
|
-
}
|
|
13390
|
-
if (winningSide) {
|
|
13391
|
-
if (participantWon) {
|
|
13392
|
-
participantIdMap[relevantParticipantId].wins++;
|
|
13393
|
-
} else {
|
|
13394
|
-
participantIdMap[relevantParticipantId].losses++;
|
|
13395
|
-
}
|
|
13396
|
-
}
|
|
13397
|
-
}
|
|
13398
|
-
);
|
|
13399
|
-
});
|
|
13400
|
-
if (Array.isArray(matchUp.potentialParticipants)) {
|
|
13401
|
-
const potentialParticipantIds = getParticipantIds(
|
|
13402
|
-
matchUp.potentialParticipants.flat()
|
|
13403
|
-
);
|
|
13404
|
-
potentialParticipantIds?.forEach((participantId) => {
|
|
13405
|
-
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
13406
|
-
relevantParticipantIds?.forEach(({ relevantParticipantId }) => {
|
|
13407
|
-
participantIdMap[relevantParticipantId].potentialMatchUps[matchUpId] = definedAttributes({
|
|
13408
|
-
drawId,
|
|
13409
|
-
eventId,
|
|
13410
|
-
eventType,
|
|
13411
|
-
matchUpId,
|
|
13412
|
-
matchUpType,
|
|
13413
|
-
matchUpFormat,
|
|
13414
|
-
roundName,
|
|
13415
|
-
roundNumber,
|
|
13416
|
-
roundPosition,
|
|
13417
|
-
schedule,
|
|
13418
|
-
tieFormat,
|
|
13419
|
-
structureName,
|
|
13420
|
-
tournamentId,
|
|
13421
|
-
potential: true
|
|
13422
|
-
});
|
|
13423
|
-
});
|
|
13424
|
-
});
|
|
13425
|
-
}
|
|
13426
|
-
}
|
|
13427
|
-
|
|
13428
|
-
function addParticipantContext(params) {
|
|
13429
|
-
const participantIdsWithConflicts = [];
|
|
13430
|
-
const eventsPublishStatuses = {};
|
|
13431
|
-
const derivedDrawInfo = {};
|
|
13432
|
-
const participantIdMap = {};
|
|
13433
|
-
const initializeParticipantId = (participantId) => {
|
|
13434
|
-
if (!participantIdMap[participantId])
|
|
13435
|
-
participantIdMap[participantId] = {
|
|
13436
|
-
groupParticipantIds: [],
|
|
13437
|
-
teamParticipantIds: [],
|
|
13438
|
-
pairParticipantIds: [],
|
|
13439
|
-
potentialMatchUps: {},
|
|
13440
|
-
scheduleItems: [],
|
|
13441
|
-
opponents: {},
|
|
13442
|
-
matchUps: {},
|
|
13443
|
-
events: {},
|
|
13444
|
-
groups: [],
|
|
13445
|
-
teams: [],
|
|
13446
|
-
draws: {},
|
|
13447
|
-
losses: 0,
|
|
13448
|
-
wins: 0
|
|
13449
|
-
};
|
|
13450
|
-
};
|
|
13451
|
-
const { tournamentRecord, participantFilters, allTournamentParticipants } = params;
|
|
13452
|
-
const { relevantParticipantIdsMap } = getRelevantParticipantIdsMap({
|
|
13453
|
-
processParticipantId: initializeParticipantId,
|
|
13454
|
-
tournamentRecord
|
|
13455
|
-
});
|
|
13456
|
-
const targetParticipantIds = participantFilters?.participantIds;
|
|
13457
|
-
const getRelevantParticipantIds = (participantId) => {
|
|
13458
|
-
const relevantParticipantIds = participantId && relevantParticipantIdsMap[participantId] || [];
|
|
13459
|
-
relevantParticipantIds.push(participantId);
|
|
13460
|
-
return relevantParticipantIds.some(
|
|
13461
|
-
(obj) => !targetParticipantIds || targetParticipantIds.includes(obj.relevantParticipantId)
|
|
13462
|
-
) ? relevantParticipantIds : [];
|
|
13463
|
-
};
|
|
13464
|
-
params.withGroupings && allTournamentParticipants.forEach((participant) => {
|
|
13465
|
-
if (participant.participantType === GROUP) {
|
|
13466
|
-
const groupParticipantId = participant.participantId;
|
|
13467
|
-
participant?.individualParticipantIds?.forEach((participantId) => {
|
|
13468
|
-
if (!participantIdMap[participantId].groupParticipantIds.includes(
|
|
13469
|
-
groupParticipantId
|
|
13470
|
-
)) {
|
|
13471
|
-
participantIdMap[participantId].groupParticipantIds.push(
|
|
13472
|
-
groupParticipantId
|
|
13473
|
-
);
|
|
13474
|
-
participantIdMap[participantId].groups.push({
|
|
13475
|
-
participantRoleResponsibilities: participant.participantRoleResponsibilities,
|
|
13476
|
-
participantOtherName: participant.participantOtherName,
|
|
13477
|
-
participantName: participant.participantName,
|
|
13478
|
-
participantId: participant.participantId
|
|
13479
|
-
});
|
|
13480
|
-
}
|
|
13481
|
-
});
|
|
13482
|
-
}
|
|
13483
|
-
if (participant.participantType === TEAM$1) {
|
|
13484
|
-
const teamParticipantId = participant.participantId;
|
|
13485
|
-
participant?.individualParticipantIds?.forEach((participantId) => {
|
|
13486
|
-
if (!participantIdMap[participantId]?.teamParticipantIds?.includes(
|
|
13487
|
-
teamParticipantId
|
|
13488
|
-
)) {
|
|
13489
|
-
participantIdMap[participantId]?.teamParticipantIds.push(
|
|
13490
|
-
teamParticipantId
|
|
13491
|
-
);
|
|
13492
|
-
participantIdMap[participantId]?.teams.push({
|
|
13493
|
-
participantRoleResponsibilities: participant.participantRoleResponsibilities,
|
|
13494
|
-
participantOtherName: participant.participantOtherName,
|
|
13495
|
-
participantName: participant.participantName,
|
|
13496
|
-
participantId: participant.participantId,
|
|
13497
|
-
teamId: participant.teamId
|
|
13498
|
-
});
|
|
13499
|
-
}
|
|
13500
|
-
});
|
|
13501
|
-
}
|
|
13502
|
-
if (participant.participantType === PAIR) {
|
|
13503
|
-
const pairParticipantId = participant.participantId;
|
|
13504
|
-
participant?.individualParticipantIds?.forEach((participantId) => {
|
|
13505
|
-
if (participantIdMap[participantId] && !participantIdMap[participantId].pairParticipantIds.includes(
|
|
13506
|
-
pairParticipantId
|
|
13507
|
-
)) {
|
|
13508
|
-
participantIdMap[participantId].pairParticipantIds.push(
|
|
13509
|
-
pairParticipantId
|
|
13510
|
-
);
|
|
13511
|
-
}
|
|
13512
|
-
});
|
|
13513
|
-
}
|
|
13514
|
-
});
|
|
13515
|
-
if (params.withMatchUps) {
|
|
13516
|
-
getMatchUpDependencies({ tournamentRecord });
|
|
13517
|
-
}
|
|
13518
|
-
if (params.withScheduleItems || params.scheduleAnalysis || params.withStatistics || params.withOpponents || params.withMatchUps || params.withSeeding || params.withEvents || params.withDraws) {
|
|
13519
|
-
params.tournamentEvents?.forEach((rawEvent) => {
|
|
13520
|
-
const event = makeDeepCopy(rawEvent, true, true);
|
|
13521
|
-
const flightProfile = getFlightProfile({ event }).flightProfile;
|
|
13522
|
-
const eventDrawsCount = flightProfile?.flights?.length || event.drawDefinitions?.length || 0;
|
|
13523
|
-
(event.drawDefinitions || []).forEach((drawDefinition, i) => {
|
|
13524
|
-
if (event?.eventType === TEAM$1) {
|
|
13525
|
-
const { extension } = findExtension$2({
|
|
13526
|
-
element: rawEvent.drawDefinitions[i],
|
|
13527
|
-
// rawEvent because deepCopy has converted extensions
|
|
13528
|
-
name: LINEUPS
|
|
13529
|
-
});
|
|
13530
|
-
if (extension)
|
|
13531
|
-
drawDefinition.extensions = [extension];
|
|
13532
|
-
}
|
|
13533
|
-
});
|
|
13534
|
-
const { eventId, eventName, eventType, category } = event;
|
|
13535
|
-
const eventInfo = { eventId, eventName, eventType, category };
|
|
13536
|
-
const extensionKeys = event && Object.keys(event).filter((key) => key.startsWith("_"));
|
|
13537
|
-
extensionKeys?.forEach(
|
|
13538
|
-
(extensionKey) => eventInfo[extensionKey] = event[extensionKey]
|
|
13539
|
-
);
|
|
13540
|
-
const eventEntries = event.entries || [];
|
|
13541
|
-
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
13542
|
-
const { timeItem } = getEventTimeItem({
|
|
13543
|
-
itemType,
|
|
13544
|
-
event
|
|
13545
|
-
});
|
|
13546
|
-
if (timeItem?.itemValue?.PUBLIC) {
|
|
13547
|
-
const { drawIds: publishedDrawIds = [], seeding } = timeItem.itemValue.PUBLIC || {};
|
|
13548
|
-
const publishedSeeding = {
|
|
13549
|
-
published: void 0,
|
|
13550
|
-
// seeding can be present for all entries in an event when no flights have been defined
|
|
13551
|
-
seedingScaleNames: [],
|
|
13552
|
-
drawIds: []
|
|
13553
|
-
// seeding can be specific to drawIds
|
|
13554
|
-
};
|
|
13555
|
-
if (seeding)
|
|
13556
|
-
Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
|
|
13557
|
-
eventsPublishStatuses[eventId] = {
|
|
13558
|
-
publishedDrawIds,
|
|
13559
|
-
publishedSeeding
|
|
13560
|
-
};
|
|
13561
|
-
}
|
|
13562
|
-
const disallowedConstants = [
|
|
13563
|
-
...Object.values(extensionConstants)
|
|
13564
|
-
];
|
|
13565
|
-
const disallowedKeys = disallowedConstants.map(
|
|
13566
|
-
(constant) => `_${constant}`
|
|
13567
|
-
);
|
|
13568
|
-
const filteredEventInfo = eventInfo && Object.keys(eventInfo).filter((key) => !disallowedKeys.includes(key)).reduce((obj, key) => {
|
|
13569
|
-
obj[key] = eventInfo[key];
|
|
13570
|
-
return obj;
|
|
13571
|
-
}, {});
|
|
13572
|
-
eventEntries?.filter((entry) => entry?.participantId).forEach((entry) => {
|
|
13573
|
-
const { participantId, entryStage, entryStatus, entryPosition } = entry;
|
|
13574
|
-
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
13575
|
-
relevantParticipantIds?.forEach(({ relevantParticipantId }) => {
|
|
13576
|
-
if (!participantIdMap[relevantParticipantId])
|
|
13577
|
-
initializeParticipantId(relevantParticipantId);
|
|
13578
|
-
participantIdMap[relevantParticipantId].events[eventId] = {
|
|
13579
|
-
...filteredEventInfo,
|
|
13580
|
-
partnerParticipantIds: [],
|
|
13581
|
-
entryPosition,
|
|
13582
|
-
entryStatus,
|
|
13583
|
-
entryStage,
|
|
13584
|
-
drawIds: [],
|
|
13585
|
-
eventId
|
|
13586
|
-
};
|
|
13587
|
-
});
|
|
13588
|
-
});
|
|
13589
|
-
const addDrawData = ({ drawEntry, drawId }) => {
|
|
13590
|
-
const { participantId, entryStage, entryStatus, entryPosition } = drawEntry;
|
|
13591
|
-
const relevantParticipantIds = getRelevantParticipantIds(participantId);
|
|
13592
|
-
relevantParticipantIds?.forEach(({ relevantParticipantId }) => {
|
|
13593
|
-
if (!participantIdMap[relevantParticipantId].events[eventId]) {
|
|
13594
|
-
participantIdMap[relevantParticipantId].events[eventId] = {
|
|
13595
|
-
...filteredEventInfo,
|
|
13596
|
-
partnerParticipantIds: [],
|
|
13597
|
-
entryPosition,
|
|
13598
|
-
entryStatus,
|
|
13599
|
-
entryStage,
|
|
13600
|
-
drawIds: [],
|
|
13601
|
-
eventId
|
|
13602
|
-
};
|
|
13603
|
-
}
|
|
13604
|
-
if (!participantIdMap[relevantParticipantId].draws[drawId]) {
|
|
13605
|
-
const positionAssignments = getDerivedPositionAssignments({
|
|
13606
|
-
participantId: relevantParticipantId,
|
|
13607
|
-
derivedDrawInfo,
|
|
13608
|
-
drawId
|
|
13609
|
-
});
|
|
13610
|
-
const seedAssignments = getDerivedSeedAssignments({
|
|
13611
|
-
participantId: relevantParticipantId,
|
|
13612
|
-
derivedDrawInfo,
|
|
13613
|
-
drawId
|
|
13614
|
-
});
|
|
13615
|
-
participantIdMap[relevantParticipantId].draws[drawId] = definedAttributes({
|
|
13616
|
-
qualifyingDrawSize: derivedDrawInfo[drawId]?.qualifyingDrawSize,
|
|
13617
|
-
drawSize: derivedDrawInfo[drawId]?.drawSize,
|
|
13618
|
-
partnerParticipantIds: [],
|
|
13619
|
-
positionAssignments,
|
|
13620
|
-
eventDrawsCount,
|
|
13621
|
-
seedAssignments,
|
|
13622
|
-
entryPosition,
|
|
13623
|
-
entryStatus,
|
|
13624
|
-
entryStage,
|
|
13625
|
-
eventId,
|
|
13626
|
-
drawId
|
|
13627
|
-
});
|
|
13628
|
-
}
|
|
13629
|
-
const eventDrawIds = participantIdMap[relevantParticipantId].events[eventId].drawIds;
|
|
13630
|
-
if (eventDrawIds && !eventDrawIds?.includes(drawId)) {
|
|
13631
|
-
participantIdMap[relevantParticipantId].events[eventId].drawIds.push(drawId);
|
|
13632
|
-
}
|
|
13633
|
-
});
|
|
13634
|
-
};
|
|
13635
|
-
const drawIdsWithDefinitions = event.drawDefinitions?.map(({ drawId }) => drawId) || [];
|
|
13636
|
-
eventInfo._flightProfile?.flights?.forEach((flight) => {
|
|
13637
|
-
const { drawId, drawEntries } = flight;
|
|
13638
|
-
if (!drawIdsWithDefinitions.includes(drawId)) {
|
|
13639
|
-
drawEntries?.forEach(
|
|
13640
|
-
(drawEntry) => addDrawData({ drawEntry, drawId })
|
|
13641
|
-
);
|
|
13642
|
-
}
|
|
13643
|
-
});
|
|
13644
|
-
const { drawDetails, derivedInfo } = getDrawDetails({
|
|
13645
|
-
eventEntries,
|
|
13646
|
-
event
|
|
13647
|
-
});
|
|
13648
|
-
Object.assign(derivedDrawInfo, derivedInfo);
|
|
13649
|
-
if (event.eventType === TEAM$1 || // for TEAM events some individual attributes can only be derived by processing
|
|
13650
|
-
params.withScheduleItems || params.scheduleAnalysis || params.withStatistics || params.withOpponents || params.withMatchUps || params.withDraws) {
|
|
13651
|
-
const matchUps = allEventMatchUps({
|
|
13652
|
-
afterRecoveryTimes: params.scheduleAnalysis,
|
|
13653
|
-
participants: allTournamentParticipants,
|
|
13654
|
-
nextMatchUps: true,
|
|
13655
|
-
tournamentRecord,
|
|
13656
|
-
inContext: true,
|
|
13657
|
-
event
|
|
13658
|
-
})?.matchUps;
|
|
13659
|
-
matchUps?.forEach(
|
|
13660
|
-
(matchUp) => processMatchUp({
|
|
13661
|
-
relevantParticipantIdsMap,
|
|
13662
|
-
participantFilters,
|
|
13663
|
-
participantIdMap,
|
|
13664
|
-
derivedDrawInfo,
|
|
13665
|
-
eventDrawsCount,
|
|
13666
|
-
drawDetails,
|
|
13667
|
-
eventType,
|
|
13668
|
-
matchUp
|
|
13669
|
-
})
|
|
13670
|
-
);
|
|
13671
|
-
}
|
|
13672
|
-
});
|
|
13673
|
-
}
|
|
13674
|
-
params.tournamentParticipants?.forEach((participant) => {
|
|
13675
|
-
const { scheduleConflicts, scheduleItems } = annotateParticipant({
|
|
13676
|
-
...params,
|
|
13677
|
-
eventsPublishStatuses,
|
|
13678
|
-
participantIdMap,
|
|
13679
|
-
derivedDrawInfo,
|
|
13680
|
-
participant
|
|
13681
|
-
});
|
|
13682
|
-
if (params.withSignInStatus) {
|
|
13683
|
-
const { timeItem } = getTimeItem({
|
|
13684
|
-
itemType: SIGN_IN_STATUS,
|
|
13685
|
-
element: participant
|
|
13686
|
-
});
|
|
13687
|
-
participant.signedIn = timeItem?.itemValue === SIGNED_IN;
|
|
13688
|
-
}
|
|
13689
|
-
if (params.withScheduleItems) {
|
|
13690
|
-
participant.scheduleItems = scheduleItems;
|
|
13691
|
-
}
|
|
13692
|
-
if (params.scheduleAnalysis) {
|
|
13693
|
-
participant.scheduleConflicts = scheduleConflicts;
|
|
13694
|
-
if (scheduleConflicts?.length && !participantIdsWithConflicts.includes(participant.participantId)) {
|
|
13695
|
-
participantIdsWithConflicts.push(participant.participantId);
|
|
13696
|
-
}
|
|
13697
|
-
}
|
|
13698
|
-
if (params.withGroupings !== false) {
|
|
13699
|
-
const participantAttributes = participantIdMap[participant.participantId];
|
|
13700
|
-
participant.groupParticipantIds = participantAttributes?.groupParticipantIds;
|
|
13701
|
-
participant.pairParticipantIds = participantAttributes?.pairParticipantIds;
|
|
13702
|
-
participant.teamParticipantIds = participantAttributes?.teamParticipantIds;
|
|
13703
|
-
participant.groups = participantAttributes?.groups;
|
|
13704
|
-
participant.teams = participantAttributes?.teams;
|
|
13705
|
-
}
|
|
13706
|
-
if (params.withTeamMatchUps) ;
|
|
13707
|
-
});
|
|
13708
|
-
return { participantIdsWithConflicts, eventsPublishStatuses };
|
|
13709
|
-
}
|
|
13710
|
-
|
|
13711
|
-
function getTournamentParticipants(params) {
|
|
13712
|
-
const {
|
|
13713
|
-
participantFilters = {},
|
|
13714
|
-
convertExtensions,
|
|
13715
|
-
policyDefinitions,
|
|
13716
|
-
withScheduleItems,
|
|
13717
|
-
scheduleAnalysis,
|
|
13718
|
-
withSignInStatus,
|
|
13719
|
-
withTeamMatchUps,
|
|
13720
|
-
// not implemented
|
|
13721
|
-
tournamentRecord,
|
|
13722
|
-
usePublishState,
|
|
13723
|
-
withScaleValues,
|
|
13724
|
-
withStatistics,
|
|
13725
|
-
withGroupings,
|
|
13726
|
-
withOpponents,
|
|
13727
|
-
withMatchUps,
|
|
13728
|
-
withSeeding,
|
|
13729
|
-
withEvents,
|
|
13730
|
-
withDraws,
|
|
13731
|
-
inContext,
|
|
13732
|
-
withISO2,
|
|
13733
|
-
withIOC
|
|
13734
|
-
} = params;
|
|
13735
|
-
if (!tournamentRecord)
|
|
13736
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
13737
|
-
if (!tournamentRecord.participants)
|
|
13738
|
-
return { error: MISSING_PARTICIPANTS };
|
|
13739
|
-
const allTournamentParticipants = tournamentRecord.participants.map(
|
|
13740
|
-
// (participant) => makeDeepCopy(participant, convertExtensions, true)
|
|
13741
|
-
(participant) => makeDeepCopy(participant, convertExtensions)
|
|
13742
|
-
// removed until Mongo/Mongoose issues resolved
|
|
13743
|
-
);
|
|
13744
|
-
if (typeof participantFilters !== "object")
|
|
13745
|
-
return { error: INVALID_OBJECT, participantFilters };
|
|
13746
|
-
if (inContext) {
|
|
13747
|
-
allTournamentParticipants?.forEach((participant) => {
|
|
13748
|
-
if ([PAIR, TEAM$2, GROUP].includes(participant.participantType)) {
|
|
13749
|
-
participant.individualParticipants = participant.individualParticipantIds?.map((participantId) => {
|
|
13750
|
-
const targetParticipant = tournamentRecord.participants.find(
|
|
13751
|
-
(p) => p.participantId === participantId
|
|
13752
|
-
);
|
|
13753
|
-
const individualParticipant = makeDeepCopy(
|
|
13754
|
-
targetParticipant,
|
|
13755
|
-
convertExtensions,
|
|
13756
|
-
true
|
|
13757
|
-
);
|
|
13758
|
-
if (withScaleValues) {
|
|
13759
|
-
const { ratings, rankings } = getScaleValues({
|
|
13760
|
-
participant: individualParticipant
|
|
13761
|
-
});
|
|
13762
|
-
individualParticipant.ratings = ratings;
|
|
13763
|
-
individualParticipant.rankings = rankings;
|
|
13764
|
-
}
|
|
13765
|
-
if (withIOC || withISO2)
|
|
13766
|
-
addNationalityCode({
|
|
13767
|
-
participant: individualParticipant,
|
|
13768
|
-
withISO2,
|
|
13769
|
-
withIOC
|
|
13770
|
-
});
|
|
13771
|
-
return individualParticipant;
|
|
13772
|
-
});
|
|
13773
|
-
}
|
|
13774
|
-
});
|
|
13775
|
-
}
|
|
13776
|
-
let tournamentParticipants = participantFilters ? filterParticipants({
|
|
13777
|
-
participants: allTournamentParticipants,
|
|
13778
|
-
participantFilters,
|
|
13779
|
-
tournamentRecord
|
|
13780
|
-
}) : allTournamentParticipants;
|
|
13781
|
-
let participantIdsWithConflicts, eventsPublishStatuses;
|
|
13782
|
-
const addContext = withScheduleItems || withSignInStatus || scheduleAnalysis || withScaleValues || withStatistics || withGroupings || withOpponents || withMatchUps || withSeeding || withEvents || withDraws || withISO2 || withIOC;
|
|
13783
|
-
if (addContext) {
|
|
13784
|
-
const result = addParticipantContext({
|
|
13785
|
-
tournamentEvents: tournamentRecord.events,
|
|
13786
|
-
allTournamentParticipants,
|
|
13787
|
-
tournamentParticipants,
|
|
13788
|
-
participantFilters,
|
|
13789
|
-
withScheduleItems,
|
|
13790
|
-
withSignInStatus,
|
|
13791
|
-
tournamentRecord,
|
|
13792
|
-
scheduleAnalysis,
|
|
13793
|
-
withTeamMatchUps,
|
|
13794
|
-
usePublishState,
|
|
13795
|
-
withScaleValues,
|
|
13796
|
-
withStatistics,
|
|
13797
|
-
withGroupings,
|
|
13798
|
-
withOpponents,
|
|
13799
|
-
withMatchUps,
|
|
13800
|
-
withSeeding,
|
|
13801
|
-
withEvents,
|
|
13802
|
-
withDraws,
|
|
13803
|
-
withISO2,
|
|
13804
|
-
withIOC
|
|
13805
|
-
});
|
|
13806
|
-
participantIdsWithConflicts = result?.participantIdsWithConflicts;
|
|
13807
|
-
eventsPublishStatuses = result?.eventsPublishStatuses;
|
|
13808
|
-
}
|
|
13809
|
-
const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
|
|
13810
|
-
if (participantAttributes?.participant) {
|
|
13811
|
-
tournamentParticipants = tournamentParticipants.map(
|
|
13812
|
-
(participant) => attributeFilter({
|
|
13813
|
-
template: participantAttributes.participant,
|
|
13814
|
-
source: participant
|
|
13815
|
-
})
|
|
13816
|
-
);
|
|
13817
|
-
}
|
|
13818
|
-
return {
|
|
13819
|
-
participantIdsWithConflicts,
|
|
13820
|
-
tournamentParticipants,
|
|
13821
|
-
eventsPublishStatuses
|
|
13822
|
-
};
|
|
13823
|
-
}
|
|
13824
|
-
|
|
13825
12851
|
function deepMerge(existing, incoming, arrayMerge) {
|
|
13826
12852
|
if (!existing && incoming)
|
|
13827
12853
|
return incoming;
|
|
@@ -13862,15 +12888,19 @@ function getCompetitionParticipants(params) {
|
|
|
13862
12888
|
let competitionParticipants = [];
|
|
13863
12889
|
const participantIdsWithConflicts = [];
|
|
13864
12890
|
const competitionParticipantIds = [];
|
|
12891
|
+
const mappedMatchUps = {};
|
|
13865
12892
|
for (const tournamentRecord of Object.values(tournamentRecords)) {
|
|
13866
12893
|
const {
|
|
13867
|
-
|
|
13868
|
-
participantIdsWithConflicts: idsWithConflicts
|
|
13869
|
-
|
|
12894
|
+
participants,
|
|
12895
|
+
participantIdsWithConflicts: idsWithConflicts,
|
|
12896
|
+
mappedMatchUps: matchUpsMap
|
|
12897
|
+
} = getParticipants({
|
|
13870
12898
|
tournamentRecord,
|
|
13871
12899
|
...params
|
|
13872
12900
|
});
|
|
13873
|
-
|
|
12901
|
+
if (matchUpsMap)
|
|
12902
|
+
Object.assign(mappedMatchUps, matchUpsMap);
|
|
12903
|
+
for (const tournamentParticipant of participants ?? []) {
|
|
13874
12904
|
const { participantId } = tournamentParticipant;
|
|
13875
12905
|
if (!competitionParticipantIds.includes(participantId)) {
|
|
13876
12906
|
competitionParticipantIds.push(participantId);
|
|
@@ -13886,13 +12916,18 @@ function getCompetitionParticipants(params) {
|
|
|
13886
12916
|
participantIdsWithConflicts.push(participantId);
|
|
13887
12917
|
});
|
|
13888
12918
|
}
|
|
13889
|
-
return {
|
|
12919
|
+
return {
|
|
12920
|
+
competitionParticipants,
|
|
12921
|
+
participantIdsWithConflicts,
|
|
12922
|
+
mappedMatchUps,
|
|
12923
|
+
...SUCCESS
|
|
12924
|
+
};
|
|
13890
12925
|
}
|
|
13891
12926
|
function publicFindParticipant({
|
|
13892
|
-
policyDefinitions,
|
|
13893
12927
|
tournamentRecords,
|
|
12928
|
+
policyDefinitions,
|
|
12929
|
+
contextProfile,
|
|
13894
12930
|
participantId,
|
|
13895
|
-
inContext,
|
|
13896
12931
|
personId
|
|
13897
12932
|
}) {
|
|
13898
12933
|
if (!tournamentRecords)
|
|
@@ -13902,15 +12937,15 @@ function publicFindParticipant({
|
|
|
13902
12937
|
let participant, tournamentId;
|
|
13903
12938
|
for (const tournamentRecord of Object.values(tournamentRecords)) {
|
|
13904
12939
|
tournamentId = tournamentRecord.tournamentId;
|
|
13905
|
-
const
|
|
12940
|
+
const participants = getParticipants({
|
|
13906
12941
|
policyDefinitions,
|
|
13907
|
-
tournamentRecord
|
|
13908
|
-
|
|
13909
|
-
});
|
|
12942
|
+
tournamentRecord
|
|
12943
|
+
}).participants ?? [];
|
|
13910
12944
|
participant = findParticipant({
|
|
13911
|
-
tournamentParticipants,
|
|
12945
|
+
tournamentParticipants: participants,
|
|
13912
12946
|
internalUse: true,
|
|
13913
12947
|
policyDefinitions,
|
|
12948
|
+
contextProfile,
|
|
13914
12949
|
participantId,
|
|
13915
12950
|
personId
|
|
13916
12951
|
});
|
|
@@ -13925,14 +12960,12 @@ function getParticipantScaleItem({
|
|
|
13925
12960
|
policyDefinitions,
|
|
13926
12961
|
scaleAttributes,
|
|
13927
12962
|
participantId,
|
|
13928
|
-
inContext,
|
|
13929
12963
|
personId
|
|
13930
12964
|
}) {
|
|
13931
12965
|
let result = publicFindParticipant({
|
|
13932
12966
|
tournamentRecords,
|
|
13933
12967
|
policyDefinitions,
|
|
13934
12968
|
participantId,
|
|
13935
|
-
inContext,
|
|
13936
12969
|
personId
|
|
13937
12970
|
});
|
|
13938
12971
|
if (result.error)
|
|
@@ -15162,7 +14195,7 @@ function positionActions$1(params) {
|
|
|
15162
14195
|
structure,
|
|
15163
14196
|
event
|
|
15164
14197
|
}).appliedPolicies ?? {};
|
|
15165
|
-
Object.assign(appliedPolicies, specifiedPolicyDefinitions
|
|
14198
|
+
Object.assign(appliedPolicies, specifiedPolicyDefinitions ?? {});
|
|
15166
14199
|
const {
|
|
15167
14200
|
actionsPolicy: positionActionsPolicy,
|
|
15168
14201
|
enabledStructures,
|
|
@@ -15319,7 +14352,7 @@ function positionActions$1(params) {
|
|
|
15319
14352
|
});
|
|
15320
14353
|
const { seedNumber, seedValue } = seedAssignments?.find(
|
|
15321
14354
|
(assignment) => assignment.participantId === participantId
|
|
15322
|
-
)
|
|
14355
|
+
) ?? {};
|
|
15323
14356
|
validActions.push({
|
|
15324
14357
|
type: SEED_VALUE,
|
|
15325
14358
|
method: SEED_VALUE_METHOD,
|
|
@@ -15345,7 +14378,7 @@ function positionActions$1(params) {
|
|
|
15345
14378
|
});
|
|
15346
14379
|
const { seedNumber } = seedAssignments?.find(
|
|
15347
14380
|
(assignment) => assignment.participantId === participantId
|
|
15348
|
-
)
|
|
14381
|
+
) ?? {};
|
|
15349
14382
|
validActions.push({
|
|
15350
14383
|
method: REMOVE_SEED_METHOD,
|
|
15351
14384
|
type: REMOVE_SEED,
|