tods-competition-factory 2.1.6 → 2.1.8
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/index.mjs +6 -6
- package/dist/tods-competition-factory.d.ts +3 -2
- package/dist/tods-competition-factory.development.cjs.js +198 -57
- 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 +8 -8
|
@@ -4961,7 +4961,8 @@ declare function generateStatCrew(params: any): (ResultType & {
|
|
|
4961
4961
|
valid?: boolean | undefined;
|
|
4962
4962
|
}) | {
|
|
4963
4963
|
success: boolean;
|
|
4964
|
-
|
|
4964
|
+
json: any[];
|
|
4965
|
+
xml: string[];
|
|
4965
4966
|
};
|
|
4966
4967
|
|
|
4967
4968
|
type GenerateLineUpsArgs = {
|
|
@@ -7903,7 +7904,7 @@ type GetStructureReportsArgs = {
|
|
|
7903
7904
|
extensionProfiles?: any[];
|
|
7904
7905
|
firstFlightOnly?: boolean;
|
|
7905
7906
|
};
|
|
7906
|
-
declare function getStructureReports(
|
|
7907
|
+
declare function getStructureReports(params: GetStructureReportsArgs): {
|
|
7907
7908
|
error: {
|
|
7908
7909
|
message: string;
|
|
7909
7910
|
code: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.1.
|
|
6
|
+
return '2.1.8';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function isFunction(obj) {
|
|
@@ -1682,10 +1682,11 @@ function getProvider() {
|
|
|
1682
1682
|
function handleCaughtError({ engineName, methodName, params, err }) {
|
|
1683
1683
|
const caughtErrorHandler = (isFunction(_globalStateProvider.handleCaughtError) && _globalStateProvider.handleCaughtError) ||
|
|
1684
1684
|
syncGlobalState$1.handleCaughtError;
|
|
1685
|
+
const { tournamentRecord, ...rest } = params;
|
|
1685
1686
|
return caughtErrorHandler({
|
|
1687
|
+
params: rest,
|
|
1686
1688
|
engineName,
|
|
1687
1689
|
methodName,
|
|
1688
|
-
params,
|
|
1689
1690
|
err,
|
|
1690
1691
|
});
|
|
1691
1692
|
}
|
|
@@ -14786,8 +14787,8 @@ function assignMatchUpDrawPosition({ inContextDrawMatchUps, sourceMatchUpStatus,
|
|
|
14786
14787
|
const matchUp = matchUpsMap?.drawMatchUps?.find((matchUp) => matchUp.matchUpId === matchUpId);
|
|
14787
14788
|
const drawPositions = matchUp?.drawPositions ?? [];
|
|
14788
14789
|
const { positionAdded, positionAssigned, updatedDrawPositions } = getUpdatedDrawPositions({
|
|
14789
|
-
drawPosition,
|
|
14790
14790
|
drawPositions,
|
|
14791
|
+
drawPosition,
|
|
14791
14792
|
});
|
|
14792
14793
|
const { positionAssignments } = getPositionAssignments$1({
|
|
14793
14794
|
drawDefinition,
|
|
@@ -38992,7 +38993,7 @@ function setEventDates(params) {
|
|
|
38992
38993
|
endDate: false,
|
|
38993
38994
|
},
|
|
38994
38995
|
{
|
|
38995
|
-
[VALIDATE]: (value) => value.every((d) => dateValidation.test(d)),
|
|
38996
|
+
[VALIDATE]: (value) => value.filter(Boolean).every((d) => dateValidation.test(d)),
|
|
38996
38997
|
[INVALID]: INVALID_DATE,
|
|
38997
38998
|
activeDates: false,
|
|
38998
38999
|
},
|
|
@@ -39003,7 +39004,8 @@ function setEventDates(params) {
|
|
|
39003
39004
|
]);
|
|
39004
39005
|
if (paramsCheck.error)
|
|
39005
39006
|
return paramsCheck;
|
|
39006
|
-
const { tournamentRecord,
|
|
39007
|
+
const { tournamentRecord, weekdays, event, startDate, endDate } = params;
|
|
39008
|
+
const activeDates = params.activeDates?.filter(Boolean);
|
|
39007
39009
|
if (startDate && endDate) {
|
|
39008
39010
|
const newStartDate = new Date(extractDate(startDate)).getTime();
|
|
39009
39011
|
const newEndDate = new Date(extractDate(endDate)).getTime();
|
|
@@ -40223,7 +40225,66 @@ function generateStatCrew(params) {
|
|
|
40223
40225
|
return paramsCheck;
|
|
40224
40226
|
const { tournamentRecord } = params;
|
|
40225
40227
|
const { startDate, tournamentId, tournamentName } = tournamentRecord;
|
|
40228
|
+
const { participantMap, matchUps, mappedMatchUps } = getParticipants({
|
|
40229
|
+
withMatchUps: true,
|
|
40230
|
+
withEvents: true,
|
|
40231
|
+
tournamentRecord,
|
|
40232
|
+
});
|
|
40226
40233
|
const teamParticipants = tournamentRecord.participants.filter((participant) => participant.participantType === TEAM);
|
|
40234
|
+
const teamMatchUps = matchUps?.filter((matchUp) => matchUp.matchUpType === TEAM) ?? [];
|
|
40235
|
+
const tieMatchUps = teamMatchUps?.reduce((t, matchUp) => {
|
|
40236
|
+
const tieMatchUps = matchUp?.tieMatchUps ?? [];
|
|
40237
|
+
return tieMatchUps ? [...t, ...tieMatchUps] : tieMatchUps;
|
|
40238
|
+
}, []) ?? [];
|
|
40239
|
+
const singles = matchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES) ?? [];
|
|
40240
|
+
const doubles = matchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES) ?? [];
|
|
40241
|
+
const allDuals = tieMatchUps.length === singles.length + doubles.length;
|
|
40242
|
+
const isDual = teamMatchUps.length === 1 && allDuals;
|
|
40243
|
+
const tournament = !allDuals ? 'Y' : 'N';
|
|
40244
|
+
const attrs = {
|
|
40245
|
+
mappedMatchUps,
|
|
40246
|
+
participantMap,
|
|
40247
|
+
tournamentName,
|
|
40248
|
+
tournamentId,
|
|
40249
|
+
tournament,
|
|
40250
|
+
startDate,
|
|
40251
|
+
};
|
|
40252
|
+
const xmlResult = [];
|
|
40253
|
+
const jsonResult = [];
|
|
40254
|
+
if (isDual) {
|
|
40255
|
+
const teamMatchUp = teamMatchUps[0];
|
|
40256
|
+
const { json, xml } = getXml({
|
|
40257
|
+
teamParticipants,
|
|
40258
|
+
teamMatchUp,
|
|
40259
|
+
...attrs,
|
|
40260
|
+
doubles,
|
|
40261
|
+
singles,
|
|
40262
|
+
});
|
|
40263
|
+
jsonResult.push(json);
|
|
40264
|
+
xmlResult.push(xml);
|
|
40265
|
+
}
|
|
40266
|
+
else {
|
|
40267
|
+
for (const teamMatchUp of teamMatchUps) {
|
|
40268
|
+
const teamParticipantIds = teamMatchUp?.sides
|
|
40269
|
+
?.map(({ participant }) => participant?.participantId)
|
|
40270
|
+
.filter(Boolean);
|
|
40271
|
+
if (teamParticipantIds?.length !== 2)
|
|
40272
|
+
continue;
|
|
40273
|
+
const teamParticipants = teamParticipantIds.map((participantId) => participantId && participantMap?.[participantId]?.participant);
|
|
40274
|
+
const { xml, json } = getXml({
|
|
40275
|
+
doubles: teamMatchUp.tieMatchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES),
|
|
40276
|
+
singles: teamMatchUp.tieMatchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES),
|
|
40277
|
+
teamParticipants,
|
|
40278
|
+
teamMatchUp,
|
|
40279
|
+
...attrs,
|
|
40280
|
+
});
|
|
40281
|
+
jsonResult.push(json);
|
|
40282
|
+
xmlResult.push(xml);
|
|
40283
|
+
}
|
|
40284
|
+
}
|
|
40285
|
+
return { json: jsonResult, xml: xmlResult, ...SUCCESS };
|
|
40286
|
+
}
|
|
40287
|
+
function getXml({ teamParticipants, mappedMatchUps, participantMap, tournamentName, tournamentId, teamMatchUp, tournament, startDate, doubles, singles, }) {
|
|
40227
40288
|
const homeTeam = teamParticipants?.find((team) => team.participantRoleResponsibilities?.includes('Home'));
|
|
40228
40289
|
const awayTeams = teamParticipants?.filter((team) => team.participantId !== homeTeam?.participantId);
|
|
40229
40290
|
const date = formatDate(startDate, '/', 'MDY');
|
|
@@ -40231,51 +40292,17 @@ function generateStatCrew(params) {
|
|
|
40231
40292
|
const homeid = homeTeam?.participantId || awayTeams?.[1]?.participantId;
|
|
40232
40293
|
const visname = awayTeams?.[0]?.participantName;
|
|
40233
40294
|
const visid = awayTeams?.[0]?.participantId;
|
|
40234
|
-
const
|
|
40235
|
-
const
|
|
40236
|
-
|
|
40237
|
-
|
|
40238
|
-
|
|
40239
|
-
const setKey = `set_${setNumber}`;
|
|
40240
|
-
const tbKey = `tie_${setNumber}`;
|
|
40241
|
-
const setValue = sideNumber === 1 ? side1Score : side2Score;
|
|
40242
|
-
const tieValue = sideNumber === 1 ? side1TiebreakScore : side2TiebreakScore;
|
|
40243
|
-
return { [setKey]: setValue, [tbKey]: tieValue };
|
|
40244
|
-
}) ?? []));
|
|
40245
|
-
const getParticipantAttibutes = ({ participant }) => {
|
|
40246
|
-
const pair = participant.individualParticipants?.length === 2;
|
|
40247
|
-
const pairTeamParticipantIds = pair
|
|
40248
|
-
? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.participantId))
|
|
40249
|
-
: [];
|
|
40250
|
-
const pairTeamIds = pair ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.teamId)) : [];
|
|
40251
|
-
const teamParticipantId = (!pair && participant.teams?.[0]?.participantId) ||
|
|
40252
|
-
(pairTeamParticipantIds?.length === 1 && pairTeamParticipantIds[0]) ||
|
|
40253
|
-
undefined;
|
|
40254
|
-
const team = (!pair && participant.teams?.[0]?.teamId) || (pairTeamIds?.length === 1 && pairTeamIds[0]) || teamParticipantId;
|
|
40255
|
-
const name = !pair ? participant.participantName : undefined;
|
|
40256
|
-
const name_1 = participant.individualParticipants?.[0]?.participantName;
|
|
40257
|
-
const name_2 = participant.individualParticipants?.[1]?.participantName;
|
|
40258
|
-
const vh = (homeid && (teamParticipantId === homeid ? 'H' : 'V')) || '';
|
|
40259
|
-
return definedAttributes({ vh, team, name, name_1, name_2 });
|
|
40260
|
-
};
|
|
40261
|
-
const mapMatchUp = (matchUp) => {
|
|
40262
|
-
const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp;
|
|
40263
|
-
const childArray = sides?.map((side) => {
|
|
40264
|
-
const { sideNumber, participant } = side;
|
|
40265
|
-
const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
|
|
40266
|
-
const scoreType = matchUpType === SINGLES ? 'singles_score' : 'doubles_score';
|
|
40267
|
-
return { [scoreType]: { ...getParticipantAttibutes({ participant }), ...scoreAttributes } };
|
|
40268
|
-
});
|
|
40269
|
-
const matchType = matchUpType === SINGLES ? 'singles_match' : 'doubles_match';
|
|
40270
|
-
return { [matchType]: { match, order, childArray } };
|
|
40271
|
-
};
|
|
40272
|
-
const json = {
|
|
40295
|
+
const uniValues = {};
|
|
40296
|
+
const teams = teamParticipants.map((teamParticipant) => ({
|
|
40297
|
+
team: { ...getTeam({ teamParticipant, teamMatchUp, uniValues, participantMap, mappedMatchUps, homeid }) },
|
|
40298
|
+
}));
|
|
40299
|
+
const json = definedAttributes({
|
|
40273
40300
|
venue: {
|
|
40274
|
-
|
|
40301
|
+
tournamentname: tournament ? tournamentName : undefined,
|
|
40275
40302
|
neutralgame: !homeTeam ? 'Y' : 'N',
|
|
40276
|
-
tournamentname: tournamentName,
|
|
40277
40303
|
gameid: tournamentId,
|
|
40278
40304
|
officials: {},
|
|
40305
|
+
tournament,
|
|
40279
40306
|
rules: {},
|
|
40280
40307
|
homename,
|
|
40281
40308
|
visname,
|
|
@@ -40283,11 +40310,108 @@ function generateStatCrew(params) {
|
|
|
40283
40310
|
visid,
|
|
40284
40311
|
date,
|
|
40285
40312
|
},
|
|
40286
|
-
|
|
40287
|
-
|
|
40288
|
-
|
|
40289
|
-
|
|
40290
|
-
return { xml,
|
|
40313
|
+
childArray: teams,
|
|
40314
|
+
singles_matches: singles?.map((matchUp) => mapMatchUp({ matchUp, homeid, uniValues })),
|
|
40315
|
+
doubles_matches: doubles?.map((matchUp) => mapMatchUp({ matchUp, homeid, uniValues })),
|
|
40316
|
+
});
|
|
40317
|
+
return { json, xml: jsonToXml({ json, tagName: 'tngame' }) };
|
|
40318
|
+
}
|
|
40319
|
+
function getParticipantAttibutes({ homeid, uniValues, participant }) {
|
|
40320
|
+
if (!participant)
|
|
40321
|
+
return {};
|
|
40322
|
+
const pair = participant.individualParticipants?.length === 2;
|
|
40323
|
+
const pairTeamParticipantIds = pair
|
|
40324
|
+
? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.participantId))
|
|
40325
|
+
: [];
|
|
40326
|
+
const pairTeamIds = pair ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.teamId)) : [];
|
|
40327
|
+
const teamParticipantId = (!pair && participant.teams?.[0]?.participantId) ||
|
|
40328
|
+
(pairTeamParticipantIds?.length === 1 && pairTeamParticipantIds[0]) ||
|
|
40329
|
+
undefined;
|
|
40330
|
+
const team = (!pair && participant.teams?.[0]?.teamId) || (pairTeamIds?.length === 1 && pairTeamIds[0]) || teamParticipantId;
|
|
40331
|
+
const name = !pair ? participant.participantName : undefined;
|
|
40332
|
+
const name_1 = participant.individualParticipants?.[0]?.participantName;
|
|
40333
|
+
const name_2 = participant.individualParticipants?.[1]?.participantName;
|
|
40334
|
+
const vh = (homeid && (teamParticipantId === homeid ? 'H' : 'V')) || '';
|
|
40335
|
+
const uni = !pair ? uniValues[teamParticipantId][participant.participantId] : undefined;
|
|
40336
|
+
const uni_1 = uniValues[teamParticipantId][participant.individualParticipants?.[0]?.participantId];
|
|
40337
|
+
const uni_2 = uniValues[teamParticipantId][participant.individualParticipants?.[1]?.participantId];
|
|
40338
|
+
return definedAttributes({ vh, uni, uni_1, uni_2, team, name, name_1, name_2 });
|
|
40339
|
+
}
|
|
40340
|
+
function getScoreAttributes({ sets, sideNumber }) {
|
|
40341
|
+
return Object.assign({}, ...(sets?.map((set) => {
|
|
40342
|
+
const { setNumber, side1Score, side2Score, side1TiebreakScore, side2TiebreakScore } = set;
|
|
40343
|
+
const setKey = `set_${setNumber}`;
|
|
40344
|
+
const tbKey = `tie_${setNumber}`;
|
|
40345
|
+
const setValue = sideNumber === 1 ? side1Score : side2Score;
|
|
40346
|
+
const tieValue = sideNumber === 1 ? side1TiebreakScore : side2TiebreakScore;
|
|
40347
|
+
return { [setKey]: setValue, [tbKey]: tieValue };
|
|
40348
|
+
}) ?? []));
|
|
40349
|
+
}
|
|
40350
|
+
function getTeam({ teamParticipant, teamMatchUp, participantMap, mappedMatchUps, homeid, uniValues }) {
|
|
40351
|
+
const { participantId: id, participantName: name } = teamParticipant;
|
|
40352
|
+
const vh = (homeid && (id === homeid ? 'H' : 'V')) || '';
|
|
40353
|
+
const teamMatchUps = participantMap?.[id]?.matchUps;
|
|
40354
|
+
const matchUpIds = teamMatchUps && Object.keys(teamMatchUps);
|
|
40355
|
+
const teamSideNumber = teamMatchUp?.sides?.find(({ participant }) => participant.participantId === id)?.sideNumber;
|
|
40356
|
+
const setScore = teamMatchUp?.score?.sets?.[0]?.[`side${teamSideNumber}Score`] ?? 0;
|
|
40357
|
+
uniValues[id] = {};
|
|
40358
|
+
const winLoss = { SINGLES: { w: 0, l: 0 }, DOUBLES: { w: 0, l: 0 } };
|
|
40359
|
+
const doubles = [];
|
|
40360
|
+
const singles = [];
|
|
40361
|
+
let calcScore = 0;
|
|
40362
|
+
for (const matchUpId of matchUpIds ?? []) {
|
|
40363
|
+
const matchUp = mappedMatchUps?.[matchUpId];
|
|
40364
|
+
const sideNumber = matchUp.sides.find(({ participant }) => participant.participantId === id)?.sideNumber;
|
|
40365
|
+
const matchScore = matchUp.score?.sets?.[0]?.[`side${sideNumber}Score`] ?? 0;
|
|
40366
|
+
calcScore += matchScore;
|
|
40367
|
+
for (const tieMatchUp of matchUp.tieMatchUps ?? []) {
|
|
40368
|
+
const { matchUpType, winningSide } = tieMatchUp;
|
|
40369
|
+
const wl = (winningSide && (winningSide === sideNumber ? 'w' : 'l')) || '';
|
|
40370
|
+
if (wl)
|
|
40371
|
+
winLoss[matchUpType][wl] += 1;
|
|
40372
|
+
const won = wl === 'w' ? '1' : '0';
|
|
40373
|
+
const lost = wl === 'l' ? '1' : '0';
|
|
40374
|
+
if (matchUpType === SINGLES) {
|
|
40375
|
+
const pair = singles.length + 1;
|
|
40376
|
+
singles.push({ singles_pair: { pair, won, lost, tied: '0' } });
|
|
40377
|
+
}
|
|
40378
|
+
else if (matchUpType === DOUBLES) {
|
|
40379
|
+
const pair = doubles.length + 1;
|
|
40380
|
+
doubles.push({ doubles_pair: { pair, won, lost, tied: '0' } });
|
|
40381
|
+
}
|
|
40382
|
+
}
|
|
40383
|
+
}
|
|
40384
|
+
const totals = [
|
|
40385
|
+
{ singles: { childArray: singles, won: winLoss.SINGLES.w, lost: winLoss.SINGLES.l } },
|
|
40386
|
+
{ doubles: { childArray: doubles, won: winLoss.DOUBLES.w, lost: winLoss.DOUBLES.l } },
|
|
40387
|
+
];
|
|
40388
|
+
const players = [];
|
|
40389
|
+
let playerIndex = 1;
|
|
40390
|
+
for (const individualParticipantId of teamParticipant.individualParticipantIds) {
|
|
40391
|
+
const mappedParticipant = participantMap?.[individualParticipantId];
|
|
40392
|
+
if (mappedParticipant) {
|
|
40393
|
+
const { participant, counters } = mappedParticipant;
|
|
40394
|
+
const doublesStats = { won: counters?.DOUBLES?.wins || 0, lost: counters?.DOUBLES?.losses || 0 };
|
|
40395
|
+
const singlesStats = { won: counters?.SINGLES?.wins || 0, lost: counters?.SINGLES?.losses || 0 };
|
|
40396
|
+
const { participantName: name, participantId } = participant;
|
|
40397
|
+
uniValues[id][participantId] = playerIndex;
|
|
40398
|
+
players.push({ player: { name, uni: playerIndex, singles: singlesStats, doubles: doublesStats } });
|
|
40399
|
+
}
|
|
40400
|
+
playerIndex += 1;
|
|
40401
|
+
}
|
|
40402
|
+
const score = setScore || calcScore;
|
|
40403
|
+
return { vh, id, name, score, totals, childArray: players };
|
|
40404
|
+
}
|
|
40405
|
+
function mapMatchUp({ matchUp, homeid, uniValues }) {
|
|
40406
|
+
const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp ?? {};
|
|
40407
|
+
const childArray = sides?.map((side) => {
|
|
40408
|
+
const { sideNumber, participant } = side;
|
|
40409
|
+
const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
|
|
40410
|
+
const scoreType = matchUpType === SINGLES ? 'singles_score' : 'doubles_score';
|
|
40411
|
+
return { [scoreType]: { ...getParticipantAttibutes({ homeid, uniValues, participant }), ...scoreAttributes } };
|
|
40412
|
+
});
|
|
40413
|
+
const matchType = matchUpType === SINGLES ? 'singles_match' : 'doubles_match';
|
|
40414
|
+
return { [matchType]: { match, order, childArray } };
|
|
40291
40415
|
}
|
|
40292
40416
|
|
|
40293
40417
|
const ASC = 'ASC';
|
|
@@ -42417,6 +42541,8 @@ function doubleExitAdvancement(params) {
|
|
|
42417
42541
|
return decorateResult({ result: { ...SUCCESS }, stack });
|
|
42418
42542
|
const { matchUp: sourceMatchUp, targetMatchUps, targetLinks } = targetData;
|
|
42419
42543
|
const { loserMatchUp, winnerMatchUp, loserTargetDrawPosition } = targetMatchUps;
|
|
42544
|
+
const loserMatchUpIsEmptyExit = [WALKOVER$2, DEFAULTED].includes(loserMatchUp?.matchUpStatus) &&
|
|
42545
|
+
!loserMatchUp.sides?.map((side) => side.participantId ?? side.participant).filter(Boolean).length;
|
|
42420
42546
|
if (loserMatchUp && loserMatchUp.matchUpStatus !== BYE) {
|
|
42421
42547
|
const { loserTargetLink } = targetLinks;
|
|
42422
42548
|
if (appliedPolicies?.progression?.doubleExitPropagateBye) {
|
|
@@ -42432,7 +42558,7 @@ function doubleExitAdvancement(params) {
|
|
|
42432
42558
|
if (result.error)
|
|
42433
42559
|
return decorateResult({ result, stack });
|
|
42434
42560
|
}
|
|
42435
|
-
else {
|
|
42561
|
+
else if (!loserMatchUpIsEmptyExit) {
|
|
42436
42562
|
const { feedRound, drawPositions, matchUpId } = loserMatchUp;
|
|
42437
42563
|
const walkoverWinningSide = feedRound ? 2 : 2 - drawPositions.indexOf(loserTargetDrawPosition);
|
|
42438
42564
|
const result = conditionallyAdvanceDrawPosition({
|
|
@@ -43035,6 +43161,19 @@ function removeDoubleExit(params) {
|
|
|
43035
43161
|
});
|
|
43036
43162
|
}
|
|
43037
43163
|
const byePropagatedToLoserMatchUp = loserMatchUp?.matchUpStatus === BYE && (loserMatchUp?.feedRound || loserMatchUp?.roundNumber === 1);
|
|
43164
|
+
const isFMLC = targetData?.targetLinks?.loserTargetLink?.linkCondition === FIRST_MATCHUP;
|
|
43165
|
+
if (byePropagatedToLoserMatchUp && isFMLC) {
|
|
43166
|
+
const roundMatchUps = inContextDrawMatchUps.filter(({ roundNumber, structureId }) => structureId === matchUp.structureId && roundNumber === 1);
|
|
43167
|
+
const roundPositions = roundMatchUps.map(({ roundPosition }) => roundPosition);
|
|
43168
|
+
const pairedPosition = chunkArray(roundPositions.sort(), 2)
|
|
43169
|
+
.find((chunk) => chunk.includes(matchUp.roundPosition))
|
|
43170
|
+
.filter((position) => position !== matchUp.roundPosition)[0];
|
|
43171
|
+
const pairedMatchUpStatus = roundMatchUps.find(({ roundPosition }) => roundPosition === pairedPosition)?.matchUpStatus;
|
|
43172
|
+
const pairedMatchUpIsDoubleExit = [DOUBLE_DEFAULT, DOUBLE_WALKOVER].includes(pairedMatchUpStatus);
|
|
43173
|
+
if (pairedMatchUpIsDoubleExit) {
|
|
43174
|
+
return decorateResult({ result: { ...SUCCESS }, stack });
|
|
43175
|
+
}
|
|
43176
|
+
}
|
|
43038
43177
|
if (loserMatchUp && (loserMatchUp.matchUpStatus !== BYE || byePropagatedToLoserMatchUp)) {
|
|
43039
43178
|
const inContextLoserMatchUp = inContextDrawMatchUps.find(({ matchUpId }) => matchUpId === loserMatchUp.matchUpId);
|
|
43040
43179
|
const { structure: loserStructure } = findStructure({
|
|
@@ -52832,7 +52971,8 @@ function getAvgWTN({ eventType, matchUps, eventId, drawId }) {
|
|
|
52832
52971
|
};
|
|
52833
52972
|
}
|
|
52834
52973
|
|
|
52835
|
-
function getStructureReports(
|
|
52974
|
+
function getStructureReports(params) {
|
|
52975
|
+
const { tournamentRecord, extensionProfiles, firstFlightOnly } = params;
|
|
52836
52976
|
if (!tournamentRecord)
|
|
52837
52977
|
return { error: MISSING_TOURNAMENT_ID };
|
|
52838
52978
|
const mainStructures = [];
|
|
@@ -52879,7 +53019,7 @@ function getStructureReports({ firstFlightOnly = true, extensionProfiles, tourna
|
|
|
52879
53019
|
const drawDeletionsExtension = extensions?.find((x) => x.name === DRAW_DELETIONS);
|
|
52880
53020
|
const drawDeletionsTimeItem = eventTimeItems?.find((x) => x.itemType === DRAW_DELETIONS);
|
|
52881
53021
|
const drawDeletionsCount = drawDeletionsExtension?.value?.length || drawDeletionsTimeItem?.itemValue || 0;
|
|
52882
|
-
const mapValues = Object.values(flightMap);
|
|
53022
|
+
const mapValues = Object.values(flightMap ?? {});
|
|
52883
53023
|
const minFlightNumber = flightMap && Math.min(...mapValues);
|
|
52884
53024
|
const eventSeedingBasis = getSeedingBasis(eventTimeItems);
|
|
52885
53025
|
eventStructureReports[eventId] = {
|
|
@@ -56184,7 +56324,8 @@ function updateCourtAvailability({ tournamentRecord }) {
|
|
|
56184
56324
|
}
|
|
56185
56325
|
|
|
56186
56326
|
function setTournamentDates(params) {
|
|
56187
|
-
const { tournamentRecord, startDate, endDate,
|
|
56327
|
+
const { tournamentRecord, startDate, endDate, weekdays } = params;
|
|
56328
|
+
const activeDates = params.activeDates?.filter(Boolean);
|
|
56188
56329
|
const paramsCheck = checkRequiredParameters(params, [
|
|
56189
56330
|
{ tournamentRecord: true },
|
|
56190
56331
|
{
|
|
@@ -56194,7 +56335,7 @@ function setTournamentDates(params) {
|
|
|
56194
56335
|
endDate: false,
|
|
56195
56336
|
},
|
|
56196
56337
|
{
|
|
56197
|
-
[VALIDATE]: (value) => value.every((d) => dateValidation.test(d)),
|
|
56338
|
+
[VALIDATE]: (value) => value.filter(Boolean).every((d) => dateValidation.test(d)),
|
|
56198
56339
|
[INVALID]: INVALID_DATE,
|
|
56199
56340
|
activeDates: false,
|
|
56200
56341
|
},
|
|
@@ -56209,7 +56350,7 @@ function setTournamentDates(params) {
|
|
|
56209
56350
|
return { error: INVALID_VALUES };
|
|
56210
56351
|
if (endDate && startDate && new Date(startDate) > new Date(endDate))
|
|
56211
56352
|
return { error: INVALID_VALUES };
|
|
56212
|
-
if (activeDates) {
|
|
56353
|
+
if (activeDates?.length) {
|
|
56213
56354
|
const start = startDate || tournamentRecord.startDate;
|
|
56214
56355
|
const end = endDate || tournamentRecord.endDate;
|
|
56215
56356
|
const validStart = !start || activeDates.every((d) => new Date(d) >= new Date(start));
|