tods-competition-factory 1.7.5 → 1.7.6

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 CHANGED
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
333
333
  };
334
334
 
335
335
  function factoryVersion() {
336
- return "1.7.5";
336
+ return "1.7.6";
337
337
  }
338
338
 
339
339
  function getObjectTieFormat(obj) {
@@ -4163,7 +4163,7 @@ const WIN_RATIO$1 = "winRatio";
4163
4163
  const POLICY_COMPETITIVE_BANDS_DEFAULT = {
4164
4164
  [POLICY_TYPE_COMPETITIVE_BANDS]: {
4165
4165
  policyName: "Competitive Bands Default",
4166
- competitiveProfile: {
4166
+ profileBands: {
4167
4167
  [DECISIVE]: 20,
4168
4168
  [ROUTINE]: 50
4169
4169
  }
@@ -4248,7 +4248,7 @@ function gamesPercent(scoreComponents) {
4248
4248
  return Math.round(minGames / maxGames * 100);
4249
4249
  }
4250
4250
  function pctSpread(pcts) {
4251
- return pcts.map(gamesPercent).sort().map((p) => p.toFixed(2));
4251
+ return pcts.map(gamesPercent).sort().map((p) => parseFloat(p.toFixed(2)));
4252
4252
  }
4253
4253
 
4254
4254
  function findPolicy({
@@ -4269,8 +4269,8 @@ function findPolicy({
4269
4269
  return appliedPolicies?.[policyType] ? { policy: appliedPolicies[policyType] } : { error: POLICY_NOT_FOUND };
4270
4270
  }
4271
4271
 
4272
- function getMatchUpCompetitiveness({
4273
- competitiveProfile,
4272
+ function getMatchUpCompetitiveProfile({
4273
+ profileBands,
4274
4274
  tournamentRecord,
4275
4275
  matchUp
4276
4276
  }) {
@@ -4279,15 +4279,15 @@ function getMatchUpCompetitiveness({
4279
4279
  const { score, winningSide } = matchUp;
4280
4280
  if (!winningSide)
4281
4281
  return { error: INVALID_VALUES };
4282
- const policy = !competitiveProfile && tournamentRecord && findPolicy({
4282
+ const policy = !profileBands && tournamentRecord && findPolicy({
4283
4283
  policyType: POLICY_TYPE_COMPETITIVE_BANDS,
4284
4284
  tournamentRecord
4285
4285
  }).policy;
4286
- const bandProfiles = competitiveProfile || policy?.competitiveProfile || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].competitiveProfile;
4286
+ const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
4287
4287
  const scoreComponents = getScoreComponents({ score });
4288
4288
  const spread = pctSpread([scoreComponents]);
4289
4289
  const competitiveness = getBand(spread, bandProfiles);
4290
- return { ...SUCCESS, competitiveness };
4290
+ return { ...SUCCESS, competitiveness, pctSpread: spread };
4291
4291
  }
4292
4292
 
4293
4293
  function findMatchupFormatAverageTimes(params) {
@@ -8012,7 +8012,7 @@ function getAllStructureMatchUps({
8012
8012
  ...collectionDefinition.category
8013
8013
  } : context?.category;
8014
8014
  const processCodes = matchUp.processCodes?.length && matchUp.processCodes || collectionDefinition?.processCodes?.length && collectionDefinition?.processCodes || structure?.processCodes?.length && structure?.processCodes || drawDefinition?.processCodes?.length && drawDefinition?.processCodes || event2?.processCodes?.length && event2?.processCodes || tournamentRecord?.processCodes;
8015
- const competitiveness = contextProfile?.withCompetitiveness && getMatchUpCompetitiveness({ ...contextContent, matchUp }).competitiveness;
8015
+ const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
8016
8016
  const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
8017
8017
  const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
8018
8018
  const matchUpWithContext = {
@@ -8028,7 +8028,7 @@ function getAllStructureMatchUps({
8028
8028
  finishingPositionRange,
8029
8029
  abbreviatedRoundName,
8030
8030
  drawPositionsRange,
8031
- competitiveness,
8031
+ competitiveProfile,
8032
8032
  structureName,
8033
8033
  stageSequence,
8034
8034
  drawPositions,
@@ -13381,13 +13381,19 @@ const ratingConstants = {
13381
13381
  };
13382
13382
 
13383
13383
  const ratingsParameters = {
13384
- [ELO]: { range: [0, 3e3], decimalsCount: 0, defaultInitialization: 1500 },
13384
+ [ELO]: {
13385
+ defaultInitialization: 1500,
13386
+ decimalsCount: 0,
13387
+ range: [0, 3e3],
13388
+ ascending: true
13389
+ },
13385
13390
  [NTRP]: {
13386
13391
  accessors: ["ntrpRating", "dntrpRatingHundredths"],
13387
13392
  attributes: { ustaRatingType: "" },
13388
13393
  accessor: "dntrpRatingHundredths",
13389
13394
  defaultInitialization: 3,
13390
13395
  decimalsCount: 1,
13396
+ ascending: true,
13391
13397
  range: [1, 7]
13392
13398
  },
13393
13399
  [UTR]: {
@@ -13395,6 +13401,7 @@ const ratingsParameters = {
13395
13401
  accessors: ["utrRating"],
13396
13402
  accessor: "utrRating",
13397
13403
  decimalsCount: 2,
13404
+ ascending: true,
13398
13405
  range: [1, 16]
13399
13406
  },
13400
13407
  [WTN]: {
@@ -13402,6 +13409,7 @@ const ratingsParameters = {
13402
13409
  accessors: ["wtnRating", "confidence"],
13403
13410
  defaultInitialization: 23,
13404
13411
  accessor: "wtnRating",
13412
+ ascending: false,
13405
13413
  decimalsCount: 2,
13406
13414
  range: [40, 1]
13407
13415
  }
@@ -32229,8 +32237,8 @@ function checkSchedulingProfile$1({ tournamentRecords }) {
32229
32237
  }
32230
32238
 
32231
32239
  function scheduledSortedMatchUps({
32232
- matchUps = [],
32233
- schedulingProfile
32240
+ schedulingProfile,
32241
+ matchUps = []
32234
32242
  }) {
32235
32243
  const profileHash = {};
32236
32244
  const getHash = ({ eventId, drawId, structureId, roundNumber }) => {
@@ -46724,6 +46732,10 @@ function removeDelegatedOutcome$1({ drawDefinition, event, matchUpId }) {
46724
46732
  });
46725
46733
  }
46726
46734
 
46735
+ function stringSort(a, b) {
46736
+ return (a || "").localeCompare(b || "");
46737
+ }
46738
+
46727
46739
  function generateCandidate({
46728
46740
  maxIterations = 4e3,
46729
46741
  // cap the processing intensity of the candidate generator
@@ -46858,7 +46870,7 @@ function roundCandidate({
46858
46870
  return { value: candidateValue, participantIdPairings, maxDelta, maxDiff };
46859
46871
  }
46860
46872
  function pairingHash(id1, id2) {
46861
- return [id1, id2].sort().join("|");
46873
+ return [id1, id2].sort(stringSort).join("|");
46862
46874
  }
46863
46875
 
46864
46876
  function getPairingsData({ participantIds }) {
@@ -52897,6 +52909,20 @@ function setTournamentStatus({ tournamentRecord, status }) {
52897
52909
  return { ...SUCCESS };
52898
52910
  }
52899
52911
 
52912
+ function addOnlineResource({
52913
+ tournamentRecord,
52914
+ onlineResource
52915
+ }) {
52916
+ if (!tournamentRecord)
52917
+ return { error: MISSING_TOURNAMENT_RECORD };
52918
+ if (!onlineResource)
52919
+ return { error: MISSING_VALUE };
52920
+ if (!tournamentRecord.onlineResources)
52921
+ tournamentRecord.onlineResources = [];
52922
+ tournamentRecord.onlineResources.push(onlineResource);
52923
+ return { ...SUCCESS };
52924
+ }
52925
+
52900
52926
  function analyzeDraws({ tournamentRecord }) {
52901
52927
  if (!tournamentRecord)
52902
52928
  return { error: MISSING_TOURNAMENT_RECORD };
@@ -53175,10 +53201,11 @@ function removeInvalidScheduling({ tournamentRecord }) {
53175
53201
  }
53176
53202
 
53177
53203
  const tournamentGovernor = {
53178
- addNotes,
53179
- removeNotes,
53180
- analyzeDraws,
53181
53204
  analyzeTournament,
53205
+ analyzeDraws,
53206
+ addOnlineResource,
53207
+ removeNotes,
53208
+ addNotes,
53182
53209
  completeDrawMatchUps,
53183
53210
  getRounds,
53184
53211
  getProfileRounds,
@@ -58227,11 +58254,9 @@ function getPredictiveAccuracy(params) {
58227
58254
  let { matchUps } = params;
58228
58255
  const {
58229
58256
  tournamentRecord,
58230
- ascending = true,
58231
58257
  drawDefinition,
58232
58258
  excludeMargin,
58233
58259
  exclusionRule,
58234
- valueAccessor,
58235
58260
  zoneDoubling,
58236
58261
  matchUpType,
58237
58262
  zoneMargin,
@@ -58246,6 +58271,9 @@ function getPredictiveAccuracy(params) {
58246
58271
  return { error: INVALID_VALUES, info: { matchUpType } };
58247
58272
  if (matchUps && !validMatchUps(matchUps))
58248
58273
  return { error: INVALID_VALUES, context: { matchUps } };
58274
+ const scaleProfile = ratingsParameters[scaleName];
58275
+ const ascending = scaleProfile?.ascending ?? params.ascending ?? false;
58276
+ const valueAccessor = scaleProfile?.accessor ?? params.valueAccessor;
58249
58277
  const contextProfile = { withScaleValues: true, withCompetitiveness: true };
58250
58278
  const contextFilters = {
58251
58279
  matchUpTypes: matchUpType ? [matchUpType] : [SINGLES$1, DOUBLES$1]
@@ -58295,7 +58323,7 @@ function getPredictiveAccuracy(params) {
58295
58323
  scaleName
58296
58324
  });
58297
58325
  const marginCalc = !zoneDoubling || matchUpType === SINGLES$1 ? zoneMargin : zoneMargin * 2;
58298
- const zoneData = zoneMargin && relevantMatchUps.map(({ competitiveness, matchUpType: matchUpType2, score, sides }) => {
58326
+ const zoneData = zoneMargin && relevantMatchUps.map(({ competitiveProfile, matchUpType: matchUpType2, score, sides }) => {
58299
58327
  const sideValues = getSideValues({
58300
58328
  valueAccessor,
58301
58329
  matchUpType: matchUpType2,
@@ -58303,7 +58331,11 @@ function getPredictiveAccuracy(params) {
58303
58331
  sides
58304
58332
  });
58305
58333
  const valuesGap = Math.abs(sideValues[0].value - sideValues[1].value);
58306
- return { competitiveness, score, valuesGap };
58334
+ return {
58335
+ competitiveness: competitiveProfile?.competitiveness,
58336
+ valuesGap,
58337
+ score
58338
+ };
58307
58339
  }).filter(({ valuesGap }) => {
58308
58340
  return valuesGap <= marginCalc;
58309
58341
  });
@@ -58471,7 +58503,7 @@ function getGroupingAccuracy({
58471
58503
  });
58472
58504
  continue;
58473
58505
  }
58474
- const signedGap = ascending ? valuesGap * -1 : valuesGap;
58506
+ const signedGap = ascending ? valuesGap : valuesGap * -1;
58475
58507
  const winningScoreString = winningSide === 1 ? score?.scoreStringSide1 : score?.scoreStringSide2;
58476
58508
  if (signedGap > 0) {
58477
58509
  accuracy.affirmative.push({
@@ -58545,18 +58577,14 @@ function getMatchUpFormat({
58545
58577
  };
58546
58578
  }
58547
58579
 
58548
- function getMatchUpsStats({
58549
- competitiveProfile,
58550
- tournamentRecord,
58551
- matchUps
58552
- }) {
58580
+ function getMatchUpsStats({ profileBands, tournamentRecord, matchUps }) {
58553
58581
  if (!validMatchUps(matchUps))
58554
58582
  return { error: MISSING_MATCHUPS };
58555
- const policy = !competitiveProfile && findPolicy({
58583
+ const policy = !profileBands && findPolicy({
58556
58584
  policyType: POLICY_TYPE_COMPETITIVE_BANDS,
58557
58585
  tournamentRecord
58558
58586
  }).policy;
58559
- const bandProfiles = competitiveProfile || policy?.competitiveProfile || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].competitiveProfile;
58587
+ const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
58560
58588
  const relevantMatchUps = matchUps.filter(({ winningSide }) => winningSide);
58561
58589
  const gamesMap = relevantMatchUps.map(getScoreComponents);
58562
58590
  const categorize = (p, spread) => {
@@ -58745,7 +58773,7 @@ const queryGovernor = {
58745
58773
  getPositionAssignments,
58746
58774
  isValidMatchUpFormat: isValid,
58747
58775
  getMaxEntryPosition,
58748
- getMatchUpCompetitiveness,
58776
+ getMatchUpCompetitiveProfile,
58749
58777
  findVenue,
58750
58778
  getCourts,
58751
58779
  getVenuesAndCourts: getVenuesAndCourts$1,