tods-competition-factory 2.1.6 → 2.1.7
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.development.cjs.js +70 -5
- 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 +4 -4
|
@@ -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.7';
|
|
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
|
}
|
|
@@ -40223,6 +40224,11 @@ function generateStatCrew(params) {
|
|
|
40223
40224
|
return paramsCheck;
|
|
40224
40225
|
const { tournamentRecord } = params;
|
|
40225
40226
|
const { startDate, tournamentId, tournamentName } = tournamentRecord;
|
|
40227
|
+
const { participantMap, matchUps, mappedMatchUps } = getParticipants({
|
|
40228
|
+
withMatchUps: true,
|
|
40229
|
+
withEvents: true,
|
|
40230
|
+
tournamentRecord,
|
|
40231
|
+
});
|
|
40226
40232
|
const teamParticipants = tournamentRecord.participants.filter((participant) => participant.participantType === TEAM);
|
|
40227
40233
|
const homeTeam = teamParticipants?.find((team) => team.participantRoleResponsibilities?.includes('Home'));
|
|
40228
40234
|
const awayTeams = teamParticipants?.filter((team) => team.participantId !== homeTeam?.participantId);
|
|
@@ -40231,9 +40237,62 @@ function generateStatCrew(params) {
|
|
|
40231
40237
|
const homeid = homeTeam?.participantId || awayTeams?.[1]?.participantId;
|
|
40232
40238
|
const visname = awayTeams?.[0]?.participantName;
|
|
40233
40239
|
const visid = awayTeams?.[0]?.participantId;
|
|
40234
|
-
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps;
|
|
40235
40240
|
const singles = matchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES);
|
|
40236
40241
|
const doubles = matchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES);
|
|
40242
|
+
const uniValues = {};
|
|
40243
|
+
const getTeam = (teamParticipant) => {
|
|
40244
|
+
const { participantId: id, participantName: name } = teamParticipant;
|
|
40245
|
+
const vh = (homeid && (id === homeid ? 'H' : 'V')) || '';
|
|
40246
|
+
const teamMatchUps = participantMap?.[id]?.matchUps;
|
|
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) } }));
|
|
40237
40296
|
const getScoreAttributes = ({ sets, sideNumber }) => Object.assign({}, ...(sets?.map((set) => {
|
|
40238
40297
|
const { setNumber, side1Score, side2Score, side1TiebreakScore, side2TiebreakScore } = set;
|
|
40239
40298
|
const setKey = `set_${setNumber}`;
|
|
@@ -40243,6 +40302,8 @@ function generateStatCrew(params) {
|
|
|
40243
40302
|
return { [setKey]: setValue, [tbKey]: tieValue };
|
|
40244
40303
|
}) ?? []));
|
|
40245
40304
|
const getParticipantAttibutes = ({ participant }) => {
|
|
40305
|
+
if (!participant)
|
|
40306
|
+
return {};
|
|
40246
40307
|
const pair = participant.individualParticipants?.length === 2;
|
|
40247
40308
|
const pairTeamParticipantIds = pair
|
|
40248
40309
|
? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.participantId))
|
|
@@ -40256,10 +40317,13 @@ function generateStatCrew(params) {
|
|
|
40256
40317
|
const name_1 = participant.individualParticipants?.[0]?.participantName;
|
|
40257
40318
|
const name_2 = participant.individualParticipants?.[1]?.participantName;
|
|
40258
40319
|
const vh = (homeid && (teamParticipantId === homeid ? 'H' : 'V')) || '';
|
|
40259
|
-
|
|
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 });
|
|
40260
40324
|
};
|
|
40261
40325
|
const mapMatchUp = (matchUp) => {
|
|
40262
|
-
const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp;
|
|
40326
|
+
const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp ?? {};
|
|
40263
40327
|
const childArray = sides?.map((side) => {
|
|
40264
40328
|
const { sideNumber, participant } = side;
|
|
40265
40329
|
const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
|
|
@@ -40283,6 +40347,7 @@ function generateStatCrew(params) {
|
|
|
40283
40347
|
visid,
|
|
40284
40348
|
date,
|
|
40285
40349
|
},
|
|
40350
|
+
childArray: teams,
|
|
40286
40351
|
singles_matches: singles?.map(mapMatchUp),
|
|
40287
40352
|
doubles_matches: doubles?.map(mapMatchUp),
|
|
40288
40353
|
};
|