tods-competition-factory 1.7.4 → 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.
@@ -964,14 +964,15 @@ function getScaleValues({ participant }) {
964
964
  for (const itemType of itemTypes) {
965
965
  const scaleItem = latestScaleItem(itemType);
966
966
  if (scaleItem) {
967
- const [, type, format, scaleName] = scaleItem.itemType.split(".");
967
+ const [, type, format, scaleName, modifier] = scaleItem.itemType.split(".");
968
+ const namedScale = modifier ? `${scaleName}.${modifier}` : scaleName;
968
969
  const scaleType = type === SEEDING && "seedings" || type === RANKING && "rankings" || "ratings";
969
970
  if (!scales[scaleType][format])
970
971
  scales[scaleType][format] = [];
971
972
  scales[scaleType][format].push({
972
973
  scaleValue: scaleItem.itemValue,
973
974
  scaleDate: scaleItem.itemDate,
974
- scaleName
975
+ scaleName: namedScale
975
976
  });
976
977
  }
977
978
  }
@@ -3162,7 +3163,7 @@ const DECISIVE = "DECISIVE";
3162
3163
  const POLICY_COMPETITIVE_BANDS_DEFAULT = {
3163
3164
  [POLICY_TYPE_COMPETITIVE_BANDS]: {
3164
3165
  policyName: "Competitive Bands Default",
3165
- competitiveProfile: {
3166
+ profileBands: {
3166
3167
  [DECISIVE]: 20,
3167
3168
  [ROUTINE]: 50
3168
3169
  }
@@ -3247,7 +3248,7 @@ function gamesPercent(scoreComponents) {
3247
3248
  return Math.round(minGames / maxGames * 100);
3248
3249
  }
3249
3250
  function pctSpread(pcts) {
3250
- return pcts.map(gamesPercent).sort().map((p) => p.toFixed(2));
3251
+ return pcts.map(gamesPercent).sort().map((p) => parseFloat(p.toFixed(2)));
3251
3252
  }
3252
3253
 
3253
3254
  function findPolicy({
@@ -3268,8 +3269,8 @@ function findPolicy({
3268
3269
  return appliedPolicies?.[policyType] ? { policy: appliedPolicies[policyType] } : { error: POLICY_NOT_FOUND };
3269
3270
  }
3270
3271
 
3271
- function getMatchUpCompetitiveness({
3272
- competitiveProfile,
3272
+ function getMatchUpCompetitiveProfile({
3273
+ profileBands,
3273
3274
  tournamentRecord,
3274
3275
  matchUp
3275
3276
  }) {
@@ -3278,15 +3279,15 @@ function getMatchUpCompetitiveness({
3278
3279
  const { score, winningSide } = matchUp;
3279
3280
  if (!winningSide)
3280
3281
  return { error: INVALID_VALUES };
3281
- const policy = !competitiveProfile && tournamentRecord && findPolicy({
3282
+ const policy = !profileBands && tournamentRecord && findPolicy({
3282
3283
  policyType: POLICY_TYPE_COMPETITIVE_BANDS,
3283
3284
  tournamentRecord
3284
3285
  }).policy;
3285
- const bandProfiles = competitiveProfile || policy?.competitiveProfile || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].competitiveProfile;
3286
+ const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
3286
3287
  const scoreComponents = getScoreComponents({ score });
3287
3288
  const spread = pctSpread([scoreComponents]);
3288
3289
  const competitiveness = getBand(spread, bandProfiles);
3289
- return { ...SUCCESS, competitiveness };
3290
+ return { ...SUCCESS, competitiveness, pctSpread: spread };
3290
3291
  }
3291
3292
 
3292
3293
  function findMatchupFormatAverageTimes(params) {
@@ -5964,7 +5965,7 @@ function getAllStructureMatchUps({
5964
5965
  ...collectionDefinition.category
5965
5966
  } : context?.category;
5966
5967
  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;
5967
- const competitiveness = contextProfile?.withCompetitiveness && getMatchUpCompetitiveness({ ...contextContent, matchUp }).competitiveness;
5968
+ const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
5968
5969
  const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
5969
5970
  const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
5970
5971
  const matchUpWithContext = {
@@ -5980,7 +5981,7 @@ function getAllStructureMatchUps({
5980
5981
  finishingPositionRange,
5981
5982
  abbreviatedRoundName,
5982
5983
  drawPositionsRange,
5983
- competitiveness,
5984
+ competitiveProfile,
5984
5985
  structureName,
5985
5986
  stageSequence,
5986
5987
  drawPositions,