tods-competition-factory 2.0.53 → 2.0.54
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 +5 -5
- package/dist/tods-competition-factory.development.cjs.js +25 -7
- 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 +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.0.
|
|
6
|
+
return '2.0.54';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function isFunction(obj) {
|
|
@@ -19852,8 +19852,8 @@ function calculatePressureRatings({ participantResults, sides, score }) {
|
|
|
19852
19852
|
const { convertedRating: side1ConvertedRating } = getConvertedRating({ ratings: side1ratings, targetRatingType });
|
|
19853
19853
|
const { convertedRating: side2ConvertedRating } = getConvertedRating({ ratings: side2ratings, targetRatingType });
|
|
19854
19854
|
const { side1pressure, side2pressure } = getSideValues$1({ side1ConvertedRating, side2ConvertedRating, score });
|
|
19855
|
-
participantResults[side1?.participantId].pressureScores.push(side1pressure);
|
|
19856
|
-
participantResults[side2?.participantId].pressureScores.push(side2pressure);
|
|
19855
|
+
side1pressure && participantResults[side1?.participantId].pressureScores.push(side1pressure);
|
|
19856
|
+
side2pressure && participantResults[side2?.participantId].pressureScores.push(side2pressure);
|
|
19857
19857
|
const highRange = Math.max(...ratingsParameters[ELO].range);
|
|
19858
19858
|
const side1Variation = fixedDecimals((side2ConvertedRating - side1ConvertedRating) / highRange);
|
|
19859
19859
|
const side2Variation = fixedDecimals((side1ConvertedRating - side2ConvertedRating) / highRange);
|
|
@@ -19873,11 +19873,11 @@ function getSideValues$1({ side1ConvertedRating, side2ConvertedRating, score })
|
|
|
19873
19873
|
const gamesWonSide1 = score?.sets?.reduce((total, set) => total + (set?.side1Score ?? 0), 0);
|
|
19874
19874
|
const gamesWonSide2 = score?.sets?.reduce((total, set) => total + (set.side2Score ?? 0), 0);
|
|
19875
19875
|
const lowSide = side1ConvertedRating > side2ConvertedRating ? 2 : 1;
|
|
19876
|
-
const side1value = gamesWonSide1 * (lowRating + (lowSide === 1 ? lowSideBump : 0));
|
|
19877
|
-
const side2value = gamesWonSide2 * (lowRating + (lowSide === 2 ? lowSideBump : 0));
|
|
19876
|
+
const side1value = (gamesWonSide1 || 0) * (lowRating + (lowSide === 1 ? lowSideBump : 0));
|
|
19877
|
+
const side2value = (gamesWonSide2 || 0) * (lowRating + (lowSide === 2 ? lowSideBump : 0));
|
|
19878
19878
|
const combinedValues = side1value + side2value;
|
|
19879
|
-
const side1pressure = fixedDecimals(side1value / combinedValues);
|
|
19880
|
-
const side2pressure = fixedDecimals(side2value / combinedValues);
|
|
19879
|
+
const side1pressure = combinedValues ? fixedDecimals(side1value / combinedValues) : 0;
|
|
19880
|
+
const side2pressure = combinedValues ? fixedDecimals(side2value / combinedValues) : 0;
|
|
19881
19881
|
return { side1pressure, side2pressure };
|
|
19882
19882
|
}
|
|
19883
19883
|
|
|
@@ -20738,6 +20738,8 @@ function tallyParticipantResults({ policyDefinitions, generateReport, pressureRa
|
|
|
20738
20738
|
tallyPolicy,
|
|
20739
20739
|
subOrderMap,
|
|
20740
20740
|
});
|
|
20741
|
+
if (pressureRating)
|
|
20742
|
+
addPressureOrder({ participantResults });
|
|
20741
20743
|
if (bracketComplete && groupOrder) {
|
|
20742
20744
|
report = groupOrderReport;
|
|
20743
20745
|
order = groupOrder;
|
|
@@ -20795,6 +20797,22 @@ function tallyParticipantResults({ policyDefinitions, generateReport, pressureRa
|
|
|
20795
20797
|
}
|
|
20796
20798
|
return result;
|
|
20797
20799
|
}
|
|
20800
|
+
function addPressureOrder({ participantResults }) {
|
|
20801
|
+
const sum = (values) => values.reduce((total, value) => total + parseFloat(value), 0);
|
|
20802
|
+
const avg = (values) => parseFloat((sum(values) / values.length).toFixed(2));
|
|
20803
|
+
const pressureOrder = Object.keys(participantResults)
|
|
20804
|
+
.map((participantId) => {
|
|
20805
|
+
const participantResult = participantResults[participantId];
|
|
20806
|
+
const { pressureScores } = participantResult;
|
|
20807
|
+
const averagePressure = pressureScores?.length ? avg(pressureScores) : 0;
|
|
20808
|
+
return { participantId, averagePressure };
|
|
20809
|
+
})
|
|
20810
|
+
.sort((a, b) => (b.averagePressure || 0) - (a.averagePressure || 0))
|
|
20811
|
+
.map((results, i) => ({ ...results, order: i + 1 }));
|
|
20812
|
+
for (const item of pressureOrder) {
|
|
20813
|
+
participantResults[item.participantId].pressureOrder = item.order;
|
|
20814
|
+
}
|
|
20815
|
+
}
|
|
20798
20816
|
|
|
20799
20817
|
function createSubOrderMap({ positionAssignments }) {
|
|
20800
20818
|
const subOrderArray = (positionAssignments || [])
|