@rasifix/orienteering-utils 2.0.20 → 2.0.22
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 +8 -10
- package/package.json +1 -1
package/lib/utils/ranking.js
CHANGED
|
@@ -309,21 +309,19 @@ function defineLegs(runners) {
|
|
|
309
309
|
}, {});
|
|
310
310
|
runners.forEach(function (runner) {
|
|
311
311
|
runner.splits
|
|
312
|
-
//.filter((s) => validTime(s.time))
|
|
313
312
|
.forEach(function (split, idx) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
313
|
+
const from = idx === 0 ? "St" : runner.splits[idx - 1].code;
|
|
314
|
+
const to = split.code;
|
|
315
|
+
const code = from + "-" + to;
|
|
316
|
+
const current = legs[code];
|
|
317
|
+
const time = idx === 0 ? split.time : split.time - runner.splits[idx - 1].time;
|
|
318
|
+
if (validTime(time)) {
|
|
319
319
|
current.runners.push({
|
|
320
320
|
id: runner.id,
|
|
321
321
|
fullName: runner.fullName,
|
|
322
322
|
splitRank: 0,
|
|
323
323
|
time: split.time,
|
|
324
|
-
split:
|
|
325
|
-
? split.time
|
|
326
|
-
: split.time - runner.splits[idx - 1].time,
|
|
324
|
+
split: time,
|
|
327
325
|
});
|
|
328
326
|
}
|
|
329
327
|
});
|
|
@@ -348,7 +346,7 @@ function defineLegProperties(legs) {
|
|
|
348
346
|
return r1.split - r2.split;
|
|
349
347
|
});
|
|
350
348
|
// calculate the ideal time: take up to 5 fastest on that leg
|
|
351
|
-
var selected = leg.runners
|
|
349
|
+
var selected = leg.runners.filter((runner) => !isNaN(runner.split) && runner.split !== undefined)
|
|
352
350
|
.slice(0, Math.min(leg.runners.length, 5))
|
|
353
351
|
.map(function (runner) { return runner.split; });
|
|
354
352
|
// only if there are valid splits for this leg
|