tods-competition-factory 1.7.5 → 1.7.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.
@@ -3833,7 +3833,7 @@ const WIN_RATIO = "winRatio";
3833
3833
  const POLICY_COMPETITIVE_BANDS_DEFAULT = {
3834
3834
  [POLICY_TYPE_COMPETITIVE_BANDS]: {
3835
3835
  policyName: "Competitive Bands Default",
3836
- competitiveProfile: {
3836
+ profileBands: {
3837
3837
  [DECISIVE]: 20,
3838
3838
  [ROUTINE]: 50
3839
3839
  }
@@ -4891,7 +4891,8 @@ function resolveTieFormat({
4891
4891
 
4892
4892
  const add = (a, b) => (a || 0) + (b || 0);
4893
4893
  function getBand(spread, bandProfiles) {
4894
- return isNaN(spread) && WALKOVER || spread <= bandProfiles[DECISIVE] && DECISIVE || spread <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
4894
+ const spreadValue = Array.isArray(spread) ? spread[0] : spread;
4895
+ return isNaN(spreadValue) && WALKOVER || spreadValue <= bandProfiles[DECISIVE] && DECISIVE || spreadValue <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
4895
4896
  }
4896
4897
  function getScoreComponents({ score }) {
4897
4898
  const sets = score?.sets || [];
@@ -4922,11 +4923,11 @@ function gamesPercent(scoreComponents) {
4922
4923
  return Math.round(minGames / maxGames * 100);
4923
4924
  }
4924
4925
  function pctSpread(pcts) {
4925
- return pcts.map(gamesPercent).sort().map((p) => p.toFixed(2));
4926
+ return pcts.map(gamesPercent).sort().map((p) => parseFloat(p.toFixed(2)));
4926
4927
  }
4927
4928
 
4928
- function getMatchUpCompetitiveness({
4929
- competitiveProfile,
4929
+ function getMatchUpCompetitiveProfile({
4930
+ profileBands,
4930
4931
  tournamentRecord,
4931
4932
  matchUp
4932
4933
  }) {
@@ -4935,15 +4936,16 @@ function getMatchUpCompetitiveness({
4935
4936
  const { score, winningSide } = matchUp;
4936
4937
  if (!winningSide)
4937
4938
  return { error: INVALID_VALUES };
4938
- const policy = !competitiveProfile && tournamentRecord && findPolicy({
4939
+ const policy = !profileBands && tournamentRecord && findPolicy({
4939
4940
  policyType: POLICY_TYPE_COMPETITIVE_BANDS,
4940
4941
  tournamentRecord
4941
4942
  }).policy;
4942
- const bandProfiles = competitiveProfile || policy?.competitiveProfile || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].competitiveProfile;
4943
+ const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
4943
4944
  const scoreComponents = getScoreComponents({ score });
4944
4945
  const spread = pctSpread([scoreComponents]);
4945
4946
  const competitiveness = getBand(spread, bandProfiles);
4946
- return { ...SUCCESS, competitiveness };
4947
+ const pctSpreadValue = Array.isArray(spread) ? spread[0] : spread;
4948
+ return { ...SUCCESS, competitiveness, pctSpread: pctSpreadValue };
4947
4949
  }
4948
4950
 
4949
4951
  function findMatchupFormatAverageTimes(params) {
@@ -6771,6 +6773,9 @@ function isAdHoc({ drawDefinition, structure }) {
6771
6773
  const POLICY_ROUND_NAMING_DEFAULT = {
6772
6774
  [POLICY_TYPE_ROUND_NAMING]: {
6773
6775
  policyName: "Round Naming Default",
6776
+ namingConventions: {
6777
+ round: "Round"
6778
+ },
6774
6779
  abbreviatedRoundNamingMap: {
6775
6780
  // key is matchUpsCount for the round
6776
6781
  1: "F",
@@ -6810,6 +6815,9 @@ function getRoundContextProfile({
6810
6815
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
6811
6816
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
6812
6817
  const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
6818
+ const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
6819
+ const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
6820
+ const roundNameFallback = namingConventions.round;
6813
6821
  const stageInitial = stage && stage !== MAIN && stage[0];
6814
6822
  const stageConstants = roundNamingPolicy?.stageConstants;
6815
6823
  const stageConstant = stage && stageConstants?.[stage] || stageInitial;
@@ -6818,8 +6826,8 @@ function getRoundContextProfile({
6818
6826
  Object.assign(
6819
6827
  roundNamingProfile,
6820
6828
  ...roundProfileKeys.map((key) => {
6821
- const roundName = `Round ${key}`;
6822
- const abbreviatedRoundName = `R${key}`;
6829
+ const roundName = `${roundNameFallback} ${key}`;
6830
+ const abbreviatedRoundName = `${roundNumberAffix}${key}`;
6823
6831
  return { [key]: { roundName, abbreviatedRoundName } };
6824
6832
  })
6825
6833
  );
@@ -7167,7 +7175,7 @@ function getAllStructureMatchUps({
7167
7175
  ...collectionDefinition.category
7168
7176
  } : context?.category;
7169
7177
  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;
7170
- const competitiveness = contextProfile?.withCompetitiveness && getMatchUpCompetitiveness({ ...contextContent, matchUp }).competitiveness;
7178
+ const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
7171
7179
  const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
7172
7180
  const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
7173
7181
  const matchUpWithContext = {
@@ -7183,7 +7191,7 @@ function getAllStructureMatchUps({
7183
7191
  finishingPositionRange,
7184
7192
  abbreviatedRoundName,
7185
7193
  drawPositionsRange,
7186
- competitiveness,
7194
+ competitiveProfile,
7187
7195
  structureName,
7188
7196
  stageSequence,
7189
7197
  drawPositions,
@@ -10334,8 +10342,8 @@ function getUpdatedSchedulingProfile({
10334
10342
  }
10335
10343
 
10336
10344
  function scheduledSortedMatchUps({
10337
- matchUps = [],
10338
- schedulingProfile
10345
+ schedulingProfile,
10346
+ matchUps = []
10339
10347
  }) {
10340
10348
  const profileHash = {};
10341
10349
  const getHash = ({ eventId, drawId, structureId, roundNumber }) => {