tods-competition-factory 2.1.7 → 2.1.9
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 +192 -117
- 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 +7 -7
|
@@ -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.9';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function isFunction(obj) {
|
|
@@ -11100,8 +11100,7 @@ function removeDrawPosition$1({ inContextDrawMatchUps, positionAssignments, tour
|
|
|
11100
11100
|
(targetMatchUp.matchUpStatus &&
|
|
11101
11101
|
[DEFAULTED, WALKOVER$2].includes(targetMatchUp.matchUpStatus) &&
|
|
11102
11102
|
targetMatchUp.matcHUpStatus) ||
|
|
11103
|
-
|
|
11104
|
-
undefined;
|
|
11103
|
+
TO_BE_PLAYED;
|
|
11105
11104
|
targetMatchUp.matchUpStatus = newMatchUpStatus;
|
|
11106
11105
|
if (targetMatchUp.matchUpStatus && [WALKOVER$2, DEFAULTED].includes(targetMatchUp.matchUpStatus))
|
|
11107
11106
|
targetMatchUp.winningSide = undefined;
|
|
@@ -11119,9 +11118,9 @@ function removeDrawPosition$1({ inContextDrawMatchUps, positionAssignments, tour
|
|
|
11119
11118
|
}
|
|
11120
11119
|
modifyMatchUpNotice({
|
|
11121
11120
|
tournamentId: tournamentRecord?.tournamentId,
|
|
11121
|
+
context: `${stack}-${drawPosition}`,
|
|
11122
11122
|
eventId: event?.eventId,
|
|
11123
11123
|
matchUp: targetMatchUp,
|
|
11124
|
-
context: `${stack}-${drawPosition}`,
|
|
11125
11124
|
drawDefinition,
|
|
11126
11125
|
});
|
|
11127
11126
|
}
|
|
@@ -14787,8 +14786,8 @@ function assignMatchUpDrawPosition({ inContextDrawMatchUps, sourceMatchUpStatus,
|
|
|
14787
14786
|
const matchUp = matchUpsMap?.drawMatchUps?.find((matchUp) => matchUp.matchUpId === matchUpId);
|
|
14788
14787
|
const drawPositions = matchUp?.drawPositions ?? [];
|
|
14789
14788
|
const { positionAdded, positionAssigned, updatedDrawPositions } = getUpdatedDrawPositions({
|
|
14790
|
-
drawPosition,
|
|
14791
14789
|
drawPositions,
|
|
14790
|
+
drawPosition,
|
|
14792
14791
|
});
|
|
14793
14792
|
const { positionAssignments } = getPositionAssignments$1({
|
|
14794
14793
|
drawDefinition,
|
|
@@ -38993,7 +38992,7 @@ function setEventDates(params) {
|
|
|
38993
38992
|
endDate: false,
|
|
38994
38993
|
},
|
|
38995
38994
|
{
|
|
38996
|
-
[VALIDATE]: (value) => value.every((d) => dateValidation.test(d)),
|
|
38995
|
+
[VALIDATE]: (value) => value.filter(Boolean).every((d) => dateValidation.test(d)),
|
|
38997
38996
|
[INVALID]: INVALID_DATE,
|
|
38998
38997
|
activeDates: false,
|
|
38999
38998
|
},
|
|
@@ -39004,7 +39003,8 @@ function setEventDates(params) {
|
|
|
39004
39003
|
]);
|
|
39005
39004
|
if (paramsCheck.error)
|
|
39006
39005
|
return paramsCheck;
|
|
39007
|
-
const { tournamentRecord,
|
|
39006
|
+
const { tournamentRecord, weekdays, event, startDate, endDate } = params;
|
|
39007
|
+
const activeDates = params.activeDates?.filter(Boolean);
|
|
39008
39008
|
if (startDate && endDate) {
|
|
39009
39009
|
const newStartDate = new Date(extractDate(startDate)).getTime();
|
|
39010
39010
|
const newEndDate = new Date(extractDate(endDate)).getTime();
|
|
@@ -40230,6 +40230,60 @@ function generateStatCrew(params) {
|
|
|
40230
40230
|
tournamentRecord,
|
|
40231
40231
|
});
|
|
40232
40232
|
const teamParticipants = tournamentRecord.participants.filter((participant) => participant.participantType === TEAM);
|
|
40233
|
+
const teamMatchUps = matchUps?.filter((matchUp) => matchUp.matchUpType === TEAM) ?? [];
|
|
40234
|
+
const tieMatchUps = teamMatchUps?.reduce((t, matchUp) => {
|
|
40235
|
+
const tieMatchUps = matchUp?.tieMatchUps ?? [];
|
|
40236
|
+
return tieMatchUps ? [...t, ...tieMatchUps] : tieMatchUps;
|
|
40237
|
+
}, []) ?? [];
|
|
40238
|
+
const singles = matchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES) ?? [];
|
|
40239
|
+
const doubles = matchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES) ?? [];
|
|
40240
|
+
const allDuals = tieMatchUps.length === singles.length + doubles.length;
|
|
40241
|
+
const isDual = teamMatchUps.length === 1 && allDuals;
|
|
40242
|
+
const tournament = !allDuals ? 'Y' : 'N';
|
|
40243
|
+
const attrs = {
|
|
40244
|
+
mappedMatchUps,
|
|
40245
|
+
participantMap,
|
|
40246
|
+
tournamentName,
|
|
40247
|
+
tournamentId,
|
|
40248
|
+
tournament,
|
|
40249
|
+
startDate,
|
|
40250
|
+
};
|
|
40251
|
+
const xmlResult = [];
|
|
40252
|
+
const jsonResult = [];
|
|
40253
|
+
if (isDual) {
|
|
40254
|
+
const teamMatchUp = teamMatchUps[0];
|
|
40255
|
+
const { json, xml } = getXml({
|
|
40256
|
+
teamParticipants,
|
|
40257
|
+
teamMatchUp,
|
|
40258
|
+
...attrs,
|
|
40259
|
+
doubles,
|
|
40260
|
+
singles,
|
|
40261
|
+
});
|
|
40262
|
+
jsonResult.push(json);
|
|
40263
|
+
xmlResult.push(xml);
|
|
40264
|
+
}
|
|
40265
|
+
else {
|
|
40266
|
+
for (const teamMatchUp of teamMatchUps) {
|
|
40267
|
+
const teamParticipantIds = teamMatchUp?.sides
|
|
40268
|
+
?.map(({ participant }) => participant?.participantId)
|
|
40269
|
+
.filter(Boolean);
|
|
40270
|
+
if (teamParticipantIds?.length !== 2)
|
|
40271
|
+
continue;
|
|
40272
|
+
const teamParticipants = teamParticipantIds.map((participantId) => participantId && participantMap?.[participantId]?.participant);
|
|
40273
|
+
const { xml, json } = getXml({
|
|
40274
|
+
doubles: teamMatchUp.tieMatchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES),
|
|
40275
|
+
singles: teamMatchUp.tieMatchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES),
|
|
40276
|
+
teamParticipants,
|
|
40277
|
+
teamMatchUp,
|
|
40278
|
+
...attrs,
|
|
40279
|
+
});
|
|
40280
|
+
jsonResult.push(json);
|
|
40281
|
+
xmlResult.push(xml);
|
|
40282
|
+
}
|
|
40283
|
+
}
|
|
40284
|
+
return { json: jsonResult, xml: xmlResult, ...SUCCESS };
|
|
40285
|
+
}
|
|
40286
|
+
function getXml({ teamParticipants, mappedMatchUps, participantMap, tournamentName, tournamentId, teamMatchUp, tournament, startDate, doubles, singles, }) {
|
|
40233
40287
|
const homeTeam = teamParticipants?.find((team) => team.participantRoleResponsibilities?.includes('Home'));
|
|
40234
40288
|
const awayTeams = teamParticipants?.filter((team) => team.participantId !== homeTeam?.participantId);
|
|
40235
40289
|
const date = formatDate(startDate, '/', 'MDY');
|
|
@@ -40237,109 +40291,17 @@ function generateStatCrew(params) {
|
|
|
40237
40291
|
const homeid = homeTeam?.participantId || awayTeams?.[1]?.participantId;
|
|
40238
40292
|
const visname = awayTeams?.[0]?.participantName;
|
|
40239
40293
|
const visid = awayTeams?.[0]?.participantId;
|
|
40240
|
-
const singles = matchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES);
|
|
40241
|
-
const doubles = matchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES);
|
|
40242
40294
|
const uniValues = {};
|
|
40243
|
-
const
|
|
40244
|
-
|
|
40245
|
-
|
|
40246
|
-
|
|
40247
|
-
const matchUpIds = teamMatchUps && Object.keys(teamMatchUps);
|
|
40248
|
-
uniValues[id] = {};
|
|
40249
|
-
const winLoss = { SINGLES: { w: 0, l: 0 }, DOUBLES: { w: 0, l: 0 } };
|
|
40250
|
-
const doubles = [];
|
|
40251
|
-
const singles = [];
|
|
40252
|
-
let score = 0;
|
|
40253
|
-
for (const matchUpId of matchUpIds ?? []) {
|
|
40254
|
-
const matchUp = mappedMatchUps?.[matchUpId];
|
|
40255
|
-
const sideNumber = matchUp.sides.find(({ participant }) => participant.participantId === id)?.sideNumber;
|
|
40256
|
-
const matchScore = matchUp.score?.sets?.[0]?.[`side${sideNumber}Score`] ?? 0;
|
|
40257
|
-
score += matchScore;
|
|
40258
|
-
for (const tieMatchUp of matchUp.tieMatchUps ?? []) {
|
|
40259
|
-
const { matchUpType, winningSide } = tieMatchUp;
|
|
40260
|
-
const wl = (winningSide && (winningSide === sideNumber ? 'w' : 'l')) || '';
|
|
40261
|
-
if (wl)
|
|
40262
|
-
winLoss[matchUpType][wl] += 1;
|
|
40263
|
-
const won = wl === 'w' ? '1' : '0';
|
|
40264
|
-
const lost = wl === 'l' ? '1' : '0';
|
|
40265
|
-
if (matchUpType === SINGLES) {
|
|
40266
|
-
const pair = singles.length + 1;
|
|
40267
|
-
singles.push({ singles_pair: { pair, won, lost } });
|
|
40268
|
-
}
|
|
40269
|
-
else if (matchUpType === DOUBLES) {
|
|
40270
|
-
const pair = doubles.length + 1;
|
|
40271
|
-
doubles.push({ doubles_pair: { pair, won, lost } });
|
|
40272
|
-
}
|
|
40273
|
-
}
|
|
40274
|
-
}
|
|
40275
|
-
const totals = [
|
|
40276
|
-
{ singles: { childArray: singles, won: winLoss.SINGLES.w, lost: winLoss.SINGLES.l } },
|
|
40277
|
-
{ doubles: { childArray: doubles, won: winLoss.DOUBLES.w, lost: winLoss.DOUBLES.l } },
|
|
40278
|
-
];
|
|
40279
|
-
const players = [];
|
|
40280
|
-
let playerIndex = 1;
|
|
40281
|
-
for (const individualParticipantId of teamParticipant.individualParticipantIds) {
|
|
40282
|
-
const mappedParticipant = participantMap?.[individualParticipantId];
|
|
40283
|
-
if (mappedParticipant) {
|
|
40284
|
-
const { participant, counters } = mappedParticipant;
|
|
40285
|
-
const doublesStats = { won: counters?.DOUBLES?.wins || 0, lost: counters?.DOUBLES?.losses || 0 };
|
|
40286
|
-
const singlesStats = { won: counters?.SINGLES?.wins || 0, lost: counters?.SINGLES?.losses || 0 };
|
|
40287
|
-
const { participantName: name, participantId } = participant;
|
|
40288
|
-
uniValues[id][participantId] = playerIndex;
|
|
40289
|
-
players.push({ player: { name, uni: playerIndex, singles: singlesStats, doubles: doublesStats } });
|
|
40290
|
-
}
|
|
40291
|
-
playerIndex += 1;
|
|
40292
|
-
}
|
|
40293
|
-
return { vh, id, name, score, totals, childArray: players };
|
|
40294
|
-
};
|
|
40295
|
-
const teams = teamParticipants.map((p) => ({ team: { ...getTeam(p) } }));
|
|
40296
|
-
const getScoreAttributes = ({ sets, sideNumber }) => Object.assign({}, ...(sets?.map((set) => {
|
|
40297
|
-
const { setNumber, side1Score, side2Score, side1TiebreakScore, side2TiebreakScore } = set;
|
|
40298
|
-
const setKey = `set_${setNumber}`;
|
|
40299
|
-
const tbKey = `tie_${setNumber}`;
|
|
40300
|
-
const setValue = sideNumber === 1 ? side1Score : side2Score;
|
|
40301
|
-
const tieValue = sideNumber === 1 ? side1TiebreakScore : side2TiebreakScore;
|
|
40302
|
-
return { [setKey]: setValue, [tbKey]: tieValue };
|
|
40303
|
-
}) ?? []));
|
|
40304
|
-
const getParticipantAttibutes = ({ participant }) => {
|
|
40305
|
-
if (!participant)
|
|
40306
|
-
return {};
|
|
40307
|
-
const pair = participant.individualParticipants?.length === 2;
|
|
40308
|
-
const pairTeamParticipantIds = pair
|
|
40309
|
-
? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.participantId))
|
|
40310
|
-
: [];
|
|
40311
|
-
const pairTeamIds = pair ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.teamId)) : [];
|
|
40312
|
-
const teamParticipantId = (!pair && participant.teams?.[0]?.participantId) ||
|
|
40313
|
-
(pairTeamParticipantIds?.length === 1 && pairTeamParticipantIds[0]) ||
|
|
40314
|
-
undefined;
|
|
40315
|
-
const team = (!pair && participant.teams?.[0]?.teamId) || (pairTeamIds?.length === 1 && pairTeamIds[0]) || teamParticipantId;
|
|
40316
|
-
const name = !pair ? participant.participantName : undefined;
|
|
40317
|
-
const name_1 = participant.individualParticipants?.[0]?.participantName;
|
|
40318
|
-
const name_2 = participant.individualParticipants?.[1]?.participantName;
|
|
40319
|
-
const vh = (homeid && (teamParticipantId === homeid ? 'H' : 'V')) || '';
|
|
40320
|
-
const uni = !pair ? uniValues[teamParticipantId][participant.participantId] : undefined;
|
|
40321
|
-
const uni_1 = uniValues[teamParticipantId][participant.individualParticipants?.[0]?.participantId];
|
|
40322
|
-
const uni_2 = uniValues[teamParticipantId][participant.individualParticipants?.[1]?.participantId];
|
|
40323
|
-
return definedAttributes({ vh, uni, uni_1, uni_2, team, name, name_1, name_2 });
|
|
40324
|
-
};
|
|
40325
|
-
const mapMatchUp = (matchUp) => {
|
|
40326
|
-
const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp ?? {};
|
|
40327
|
-
const childArray = sides?.map((side) => {
|
|
40328
|
-
const { sideNumber, participant } = side;
|
|
40329
|
-
const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
|
|
40330
|
-
const scoreType = matchUpType === SINGLES ? 'singles_score' : 'doubles_score';
|
|
40331
|
-
return { [scoreType]: { ...getParticipantAttibutes({ participant }), ...scoreAttributes } };
|
|
40332
|
-
});
|
|
40333
|
-
const matchType = matchUpType === SINGLES ? 'singles_match' : 'doubles_match';
|
|
40334
|
-
return { [matchType]: { match, order, childArray } };
|
|
40335
|
-
};
|
|
40336
|
-
const json = {
|
|
40295
|
+
const teams = teamParticipants.map((teamParticipant) => ({
|
|
40296
|
+
team: { ...getTeam({ teamParticipant, teamMatchUp, uniValues, participantMap, mappedMatchUps, homeid }) },
|
|
40297
|
+
}));
|
|
40298
|
+
const json = definedAttributes({
|
|
40337
40299
|
venue: {
|
|
40338
|
-
|
|
40300
|
+
tournamentname: tournament ? tournamentName : undefined,
|
|
40339
40301
|
neutralgame: !homeTeam ? 'Y' : 'N',
|
|
40340
|
-
tournamentname: tournamentName,
|
|
40341
40302
|
gameid: tournamentId,
|
|
40342
40303
|
officials: {},
|
|
40304
|
+
tournament,
|
|
40343
40305
|
rules: {},
|
|
40344
40306
|
homename,
|
|
40345
40307
|
visname,
|
|
@@ -40348,11 +40310,107 @@ function generateStatCrew(params) {
|
|
|
40348
40310
|
date,
|
|
40349
40311
|
},
|
|
40350
40312
|
childArray: teams,
|
|
40351
|
-
singles_matches: singles?.map(mapMatchUp),
|
|
40352
|
-
doubles_matches: doubles?.map(mapMatchUp),
|
|
40353
|
-
};
|
|
40354
|
-
|
|
40355
|
-
|
|
40313
|
+
singles_matches: singles?.map((matchUp) => mapMatchUp({ matchUp, homeid, uniValues })),
|
|
40314
|
+
doubles_matches: doubles?.map((matchUp) => mapMatchUp({ matchUp, homeid, uniValues })),
|
|
40315
|
+
});
|
|
40316
|
+
return { json, xml: jsonToXml({ json, tagName: 'tngame' }) };
|
|
40317
|
+
}
|
|
40318
|
+
function getParticipantAttibutes({ homeid, uniValues, participant }) {
|
|
40319
|
+
if (!participant)
|
|
40320
|
+
return {};
|
|
40321
|
+
const pair = participant.individualParticipants?.length === 2;
|
|
40322
|
+
const pairTeamParticipantIds = pair
|
|
40323
|
+
? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.participantId))
|
|
40324
|
+
: [];
|
|
40325
|
+
const pairTeamIds = pair ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.teamId)) : [];
|
|
40326
|
+
const teamParticipantId = (!pair && participant.teams?.[0]?.participantId) ||
|
|
40327
|
+
(pairTeamParticipantIds?.length === 1 && pairTeamParticipantIds[0]) ||
|
|
40328
|
+
undefined;
|
|
40329
|
+
const team = (!pair && participant.teams?.[0]?.teamId) || (pairTeamIds?.length === 1 && pairTeamIds[0]) || teamParticipantId;
|
|
40330
|
+
const name = !pair ? participant.participantName : undefined;
|
|
40331
|
+
const name_1 = participant.individualParticipants?.[0]?.participantName;
|
|
40332
|
+
const name_2 = participant.individualParticipants?.[1]?.participantName;
|
|
40333
|
+
const vh = (homeid && (teamParticipantId === homeid ? 'H' : 'V')) || '';
|
|
40334
|
+
const uni = !pair ? uniValues[teamParticipantId][participant.participantId] : undefined;
|
|
40335
|
+
const uni_1 = uniValues[teamParticipantId][participant.individualParticipants?.[0]?.participantId];
|
|
40336
|
+
const uni_2 = uniValues[teamParticipantId][participant.individualParticipants?.[1]?.participantId];
|
|
40337
|
+
return definedAttributes({ vh, uni, uni_1, uni_2, team, name, name_1, name_2 });
|
|
40338
|
+
}
|
|
40339
|
+
function getScoreAttributes({ sets, sideNumber }) {
|
|
40340
|
+
return Object.assign({}, ...(sets?.map((set) => {
|
|
40341
|
+
const { setNumber, side1Score, side2Score, side1TiebreakScore, side2TiebreakScore } = set;
|
|
40342
|
+
const setKey = `set_${setNumber}`;
|
|
40343
|
+
const tbKey = `tie_${setNumber}`;
|
|
40344
|
+
const setValue = sideNumber === 1 ? side1Score : side2Score;
|
|
40345
|
+
const tieValue = sideNumber === 1 ? side1TiebreakScore : side2TiebreakScore;
|
|
40346
|
+
return { [setKey]: setValue, [tbKey]: tieValue };
|
|
40347
|
+
}) ?? []));
|
|
40348
|
+
}
|
|
40349
|
+
function getTeam({ teamParticipant, teamMatchUp, participantMap, mappedMatchUps, homeid, uniValues }) {
|
|
40350
|
+
const { participantId: id, participantName: name } = teamParticipant;
|
|
40351
|
+
const vh = (homeid && (id === homeid ? 'H' : 'V')) || '';
|
|
40352
|
+
const teamMatchUps = participantMap?.[id]?.matchUps;
|
|
40353
|
+
const matchUpIds = teamMatchUps && Object.keys(teamMatchUps);
|
|
40354
|
+
const teamSideNumber = teamMatchUp?.sides?.find(({ participant }) => participant.participantId === id)?.sideNumber;
|
|
40355
|
+
const setScore = teamMatchUp?.score?.sets?.[0]?.[`side${teamSideNumber}Score`] ?? 0;
|
|
40356
|
+
uniValues[id] = {};
|
|
40357
|
+
const winLoss = { SINGLES: { w: 0, l: 0 }, DOUBLES: { w: 0, l: 0 } };
|
|
40358
|
+
const doubles = [];
|
|
40359
|
+
const singles = [];
|
|
40360
|
+
let calcScore = 0;
|
|
40361
|
+
for (const matchUpId of matchUpIds ?? []) {
|
|
40362
|
+
const matchUp = mappedMatchUps?.[matchUpId];
|
|
40363
|
+
const sideNumber = matchUp.sides.find(({ participant }) => participant.participantId === id)?.sideNumber;
|
|
40364
|
+
const matchScore = matchUp.score?.sets?.[0]?.[`side${sideNumber}Score`] ?? 0;
|
|
40365
|
+
calcScore += matchScore;
|
|
40366
|
+
for (const tieMatchUp of matchUp.tieMatchUps ?? []) {
|
|
40367
|
+
const { matchUpType, winningSide } = tieMatchUp;
|
|
40368
|
+
const wl = (winningSide && (winningSide === sideNumber ? 'w' : 'l')) || '';
|
|
40369
|
+
if (wl)
|
|
40370
|
+
winLoss[matchUpType][wl] += 1;
|
|
40371
|
+
const won = wl === 'w' ? '1' : '0';
|
|
40372
|
+
const lost = wl === 'l' ? '1' : '0';
|
|
40373
|
+
if (matchUpType === SINGLES) {
|
|
40374
|
+
const pair = singles.length + 1;
|
|
40375
|
+
singles.push({ singles_pair: { pair, won, lost, tied: '0' } });
|
|
40376
|
+
}
|
|
40377
|
+
else if (matchUpType === DOUBLES) {
|
|
40378
|
+
const pair = doubles.length + 1;
|
|
40379
|
+
doubles.push({ doubles_pair: { pair, won, lost, tied: '0' } });
|
|
40380
|
+
}
|
|
40381
|
+
}
|
|
40382
|
+
}
|
|
40383
|
+
const totals = [
|
|
40384
|
+
{ singles: { childArray: singles, won: winLoss.SINGLES.w, lost: winLoss.SINGLES.l } },
|
|
40385
|
+
{ doubles: { childArray: doubles, won: winLoss.DOUBLES.w, lost: winLoss.DOUBLES.l } },
|
|
40386
|
+
];
|
|
40387
|
+
const players = [];
|
|
40388
|
+
let playerIndex = 1;
|
|
40389
|
+
for (const individualParticipantId of teamParticipant.individualParticipantIds) {
|
|
40390
|
+
const mappedParticipant = participantMap?.[individualParticipantId];
|
|
40391
|
+
if (mappedParticipant) {
|
|
40392
|
+
const { participant, counters } = mappedParticipant;
|
|
40393
|
+
const doublesStats = { won: counters?.DOUBLES?.wins || 0, lost: counters?.DOUBLES?.losses || 0 };
|
|
40394
|
+
const singlesStats = { won: counters?.SINGLES?.wins || 0, lost: counters?.SINGLES?.losses || 0 };
|
|
40395
|
+
const { participantName: name, participantId } = participant;
|
|
40396
|
+
uniValues[id][participantId] = playerIndex;
|
|
40397
|
+
players.push({ player: { name, uni: playerIndex, singles: singlesStats, doubles: doublesStats } });
|
|
40398
|
+
}
|
|
40399
|
+
playerIndex += 1;
|
|
40400
|
+
}
|
|
40401
|
+
const score = setScore || calcScore;
|
|
40402
|
+
return { vh, id, name, score, totals, childArray: players };
|
|
40403
|
+
}
|
|
40404
|
+
function mapMatchUp({ matchUp, homeid, uniValues }) {
|
|
40405
|
+
const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp ?? {};
|
|
40406
|
+
const childArray = sides?.map((side) => {
|
|
40407
|
+
const { sideNumber, participant } = side;
|
|
40408
|
+
const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
|
|
40409
|
+
const scoreType = matchUpType === SINGLES ? 'singles_score' : 'doubles_score';
|
|
40410
|
+
return { [scoreType]: { ...getParticipantAttibutes({ homeid, uniValues, participant }), ...scoreAttributes } };
|
|
40411
|
+
});
|
|
40412
|
+
const matchType = matchUpType === SINGLES ? 'singles_match' : 'doubles_match';
|
|
40413
|
+
return { [matchType]: { match, order, childArray } };
|
|
40356
40414
|
}
|
|
40357
40415
|
|
|
40358
40416
|
const ASC = 'ASC';
|
|
@@ -42421,8 +42479,8 @@ function removeDirectedBye({ inContextDrawMatchUps, tournamentRecord, drawDefini
|
|
|
42421
42479
|
inContextDrawMatchUps,
|
|
42422
42480
|
tournamentRecord,
|
|
42423
42481
|
drawDefinition,
|
|
42424
|
-
matchUpsMap,
|
|
42425
42482
|
drawPosition,
|
|
42483
|
+
matchUpsMap,
|
|
42426
42484
|
structureId,
|
|
42427
42485
|
event,
|
|
42428
42486
|
});
|
|
@@ -42482,6 +42540,8 @@ function doubleExitAdvancement(params) {
|
|
|
42482
42540
|
return decorateResult({ result: { ...SUCCESS }, stack });
|
|
42483
42541
|
const { matchUp: sourceMatchUp, targetMatchUps, targetLinks } = targetData;
|
|
42484
42542
|
const { loserMatchUp, winnerMatchUp, loserTargetDrawPosition } = targetMatchUps;
|
|
42543
|
+
const loserMatchUpIsEmptyExit = [WALKOVER$2, DEFAULTED].includes(loserMatchUp?.matchUpStatus) &&
|
|
42544
|
+
!loserMatchUp.sides?.map((side) => side.participantId ?? side.participant).filter(Boolean).length;
|
|
42485
42545
|
if (loserMatchUp && loserMatchUp.matchUpStatus !== BYE) {
|
|
42486
42546
|
const { loserTargetLink } = targetLinks;
|
|
42487
42547
|
if (appliedPolicies?.progression?.doubleExitPropagateBye) {
|
|
@@ -42497,7 +42557,7 @@ function doubleExitAdvancement(params) {
|
|
|
42497
42557
|
if (result.error)
|
|
42498
42558
|
return decorateResult({ result, stack });
|
|
42499
42559
|
}
|
|
42500
|
-
else {
|
|
42560
|
+
else if (!loserMatchUpIsEmptyExit) {
|
|
42501
42561
|
const { feedRound, drawPositions, matchUpId } = loserMatchUp;
|
|
42502
42562
|
const walkoverWinningSide = feedRound ? 2 : 2 - drawPositions.indexOf(loserTargetDrawPosition);
|
|
42503
42563
|
const result = conditionallyAdvanceDrawPosition({
|
|
@@ -43100,6 +43160,19 @@ function removeDoubleExit(params) {
|
|
|
43100
43160
|
});
|
|
43101
43161
|
}
|
|
43102
43162
|
const byePropagatedToLoserMatchUp = loserMatchUp?.matchUpStatus === BYE && (loserMatchUp?.feedRound || loserMatchUp?.roundNumber === 1);
|
|
43163
|
+
const isFMLC = targetData?.targetLinks?.loserTargetLink?.linkCondition === FIRST_MATCHUP;
|
|
43164
|
+
if (byePropagatedToLoserMatchUp && isFMLC) {
|
|
43165
|
+
const roundMatchUps = inContextDrawMatchUps.filter(({ roundNumber, structureId }) => structureId === matchUp.structureId && roundNumber === 1);
|
|
43166
|
+
const roundPositions = roundMatchUps.map(({ roundPosition }) => roundPosition);
|
|
43167
|
+
const pairedPositions = chunkArray(roundPositions.sort(), 2).find((chunk) => chunk.includes(matchUp.roundPosition));
|
|
43168
|
+
const pairedMatchUpStatuses = roundMatchUps
|
|
43169
|
+
.filter(({ roundPosition }) => pairedPositions.includes(roundPosition))
|
|
43170
|
+
?.map(({ matchUpStatus }) => matchUpStatus);
|
|
43171
|
+
const pairedMatchUpIsDoubleExit = pairedMatchUpStatuses.every((matchUpStatus) => [DOUBLE_DEFAULT, DOUBLE_WALKOVER].includes(matchUpStatus));
|
|
43172
|
+
if (pairedMatchUpIsDoubleExit) {
|
|
43173
|
+
return decorateResult({ result: { ...SUCCESS }, stack });
|
|
43174
|
+
}
|
|
43175
|
+
}
|
|
43103
43176
|
if (loserMatchUp && (loserMatchUp.matchUpStatus !== BYE || byePropagatedToLoserMatchUp)) {
|
|
43104
43177
|
const inContextLoserMatchUp = inContextDrawMatchUps.find(({ matchUpId }) => matchUpId === loserMatchUp.matchUpId);
|
|
43105
43178
|
const { structure: loserStructure } = findStructure({
|
|
@@ -52897,7 +52970,8 @@ function getAvgWTN({ eventType, matchUps, eventId, drawId }) {
|
|
|
52897
52970
|
};
|
|
52898
52971
|
}
|
|
52899
52972
|
|
|
52900
|
-
function getStructureReports(
|
|
52973
|
+
function getStructureReports(params) {
|
|
52974
|
+
const { tournamentRecord, extensionProfiles, firstFlightOnly } = params;
|
|
52901
52975
|
if (!tournamentRecord)
|
|
52902
52976
|
return { error: MISSING_TOURNAMENT_ID };
|
|
52903
52977
|
const mainStructures = [];
|
|
@@ -52944,7 +53018,7 @@ function getStructureReports({ firstFlightOnly = true, extensionProfiles, tourna
|
|
|
52944
53018
|
const drawDeletionsExtension = extensions?.find((x) => x.name === DRAW_DELETIONS);
|
|
52945
53019
|
const drawDeletionsTimeItem = eventTimeItems?.find((x) => x.itemType === DRAW_DELETIONS);
|
|
52946
53020
|
const drawDeletionsCount = drawDeletionsExtension?.value?.length || drawDeletionsTimeItem?.itemValue || 0;
|
|
52947
|
-
const mapValues = Object.values(flightMap);
|
|
53021
|
+
const mapValues = Object.values(flightMap ?? {});
|
|
52948
53022
|
const minFlightNumber = flightMap && Math.min(...mapValues);
|
|
52949
53023
|
const eventSeedingBasis = getSeedingBasis(eventTimeItems);
|
|
52950
53024
|
eventStructureReports[eventId] = {
|
|
@@ -56249,7 +56323,8 @@ function updateCourtAvailability({ tournamentRecord }) {
|
|
|
56249
56323
|
}
|
|
56250
56324
|
|
|
56251
56325
|
function setTournamentDates(params) {
|
|
56252
|
-
const { tournamentRecord, startDate, endDate,
|
|
56326
|
+
const { tournamentRecord, startDate, endDate, weekdays } = params;
|
|
56327
|
+
const activeDates = params.activeDates?.filter(Boolean);
|
|
56253
56328
|
const paramsCheck = checkRequiredParameters(params, [
|
|
56254
56329
|
{ tournamentRecord: true },
|
|
56255
56330
|
{
|
|
@@ -56259,7 +56334,7 @@ function setTournamentDates(params) {
|
|
|
56259
56334
|
endDate: false,
|
|
56260
56335
|
},
|
|
56261
56336
|
{
|
|
56262
|
-
[VALIDATE]: (value) => value.every((d) => dateValidation.test(d)),
|
|
56337
|
+
[VALIDATE]: (value) => value.filter(Boolean).every((d) => dateValidation.test(d)),
|
|
56263
56338
|
[INVALID]: INVALID_DATE,
|
|
56264
56339
|
activeDates: false,
|
|
56265
56340
|
},
|
|
@@ -56274,7 +56349,7 @@ function setTournamentDates(params) {
|
|
|
56274
56349
|
return { error: INVALID_VALUES };
|
|
56275
56350
|
if (endDate && startDate && new Date(startDate) > new Date(endDate))
|
|
56276
56351
|
return { error: INVALID_VALUES };
|
|
56277
|
-
if (activeDates) {
|
|
56352
|
+
if (activeDates?.length) {
|
|
56278
56353
|
const start = startDate || tournamentRecord.startDate;
|
|
56279
56354
|
const end = endDate || tournamentRecord.endDate;
|
|
56280
56355
|
const validStart = !start || activeDates.every((d) => new Date(d) >= new Date(start));
|