@rasifix/orienteering-utils 2.0.70 → 2.0.71
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 +13 -0
- package/lib/utils/relay.js +13 -1
- package/package.json +1 -1
package/lib/utils/ranking.js
CHANGED
|
@@ -245,6 +245,19 @@ function parseRanking(runners) {
|
|
|
245
245
|
var max = leg.runners.filter(function (runner) { return !isNaN(runner.split) && runner.split !== undefined; }).map(function (runner) { return runner.split; }).reduce(function (max, split) { return Math.max(max, split - ideal); }, Number.MIN_VALUE);
|
|
246
246
|
leg.spread = [min, max];
|
|
247
247
|
});
|
|
248
|
+
// Check for anomalies in overall behind times
|
|
249
|
+
rankingRunners.forEach(function (runner) {
|
|
250
|
+
for (var i = 1; i < runner.splits.length; i++) {
|
|
251
|
+
var currentSplit = runner.splits[i];
|
|
252
|
+
var prevSplit = runner.splits[i - 1];
|
|
253
|
+
if (currentSplit.overall.behind !== undefined && prevSplit.overall.behind !== undefined && currentSplit.splitTime !== undefined) {
|
|
254
|
+
var behindDiff = currentSplit.overall.behind - prevSplit.overall.behind;
|
|
255
|
+
if (behindDiff < -currentSplit.splitTime) {
|
|
256
|
+
console.warn("Anomaly detected for runner ".concat(runner.team, " (ID: ").concat(runner.id, ") on split ").concat(currentSplit.legCode, ": overall behind decreased by ").concat(-behindDiff, "s, but split time is ").concat(currentSplit.splitTime, "s"));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
248
261
|
return {
|
|
249
262
|
courses: courses,
|
|
250
263
|
runners: rankingRunners,
|
package/lib/utils/relay.js
CHANGED
|
@@ -78,6 +78,18 @@ function parseRelayRanking(runners) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
+
// Verify that split times are increasing
|
|
82
|
+
var previousTime = 0;
|
|
83
|
+
for (var _i = 0, _a = combinedRunner.splits; _i < _a.length; _i++) {
|
|
84
|
+
var split = _a[_i];
|
|
85
|
+
var splitTime = (0, time_1.parseTime)(split.time);
|
|
86
|
+
if (splitTime !== undefined && splitTime <= previousTime) {
|
|
87
|
+
console.warn("Split times are not increasing for team ".concat(runner.team, " at leg (").concat(split.code, "): ").concat(split.time, " <= ").concat((0, time_1.formatTime)(previousTime)));
|
|
88
|
+
}
|
|
89
|
+
if (splitTime !== undefined) {
|
|
90
|
+
previousTime = splitTime;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
81
93
|
// Accumulate the total time of this leg for the next leg
|
|
82
94
|
if (runner.time) {
|
|
83
95
|
var runnerTotalTime = (0, time_1.parseTime)(runner.time);
|
|
@@ -92,5 +104,5 @@ function parseRelayRanking(runners) {
|
|
|
92
104
|
combinedRunners.push(combinedRunner);
|
|
93
105
|
});
|
|
94
106
|
// Parse the ranking as usual
|
|
95
|
-
return (0, ranking_1.parseRanking)(combinedRunners);
|
|
107
|
+
return (0, ranking_1.parseRanking)(combinedRunners.filter(function (r) { return r.time !== undefined && r.time !== "DSQ"; }));
|
|
96
108
|
}
|