@rasifix/orienteering-utils 2.0.17 → 2.0.19
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/lib/utils/ranking.js +5 -3
- package/package.json +1 -1
package/lib/utils/ranking.js
CHANGED
|
@@ -75,6 +75,9 @@ function parseRanking(runners) {
|
|
|
75
75
|
if (leg.idealSplit && idealTime > 0) {
|
|
76
76
|
leg.weight = leg.idealSplit / idealTime;
|
|
77
77
|
}
|
|
78
|
+
if (!leg.weight || isNaN(leg.weight)) {
|
|
79
|
+
console.log("invalid weight for leg ", code, leg.idealSplit, idealTime);
|
|
80
|
+
}
|
|
78
81
|
});
|
|
79
82
|
// now assing the leg information (such as idealTime, weight, ...) to the individual splits of the runners
|
|
80
83
|
assignLegInfoToSplits(rankingRunners, legs);
|
|
@@ -348,11 +351,10 @@ function defineLegProperties(legs) {
|
|
|
348
351
|
var selected = leg.runners
|
|
349
352
|
.slice(0, Math.min(leg.runners.length, 5))
|
|
350
353
|
.map(function (runner) { return runner.split; });
|
|
351
|
-
console.log("leg " + code + " selected splits: ", selected);
|
|
352
354
|
// only if there are valid splits for this leg
|
|
353
355
|
if (selected.length > 0) {
|
|
354
|
-
leg.idealSplit = Math.round(selected.reduce(sum) / selected.length);
|
|
355
|
-
if (leg.idealSplit < 0) {
|
|
356
|
+
leg.idealSplit = Math.round(selected.reduce(sum, 0) / selected.length);
|
|
357
|
+
if (leg.idealSplit < 0 || isNaN(leg.idealSplit)) {
|
|
356
358
|
console.log("invalid ideal split calculated for leg " + code, leg.idealSplit);
|
|
357
359
|
leg.idealSplit = 30;
|
|
358
360
|
}
|