@rasifix/orienteering-utils 2.0.23 → 2.0.25

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.
@@ -35,6 +35,7 @@ export interface Ranking {
35
35
  }
36
36
  export interface RankingRunner {
37
37
  id: string;
38
+ category: string;
38
39
  rank?: number;
39
40
  fullName: string;
40
41
  time?: string;
@@ -230,6 +230,7 @@ function defineRunners(runners) {
230
230
  }
231
231
  return {
232
232
  id: runner.id,
233
+ category: runner.category,
233
234
  rank: undefined,
234
235
  fullName: runner.fullName,
235
236
  time: runner.time,
@@ -309,19 +310,21 @@ function defineLegs(runners) {
309
310
  }, {});
310
311
  runners.forEach(function (runner) {
311
312
  runner.splits
313
+ //.filter((s) => validTime(s.time))
312
314
  .forEach(function (split, idx) {
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)) {
315
+ var from = idx === 0 ? "St" : runner.splits[idx - 1].code;
316
+ var to = split.code;
317
+ var code = from + "-" + to;
318
+ var current = legs[code];
319
+ if (validTime(split.time)) {
319
320
  current.runners.push({
320
321
  id: runner.id,
321
322
  fullName: runner.fullName,
322
323
  splitRank: 0,
323
324
  time: split.time,
324
- split: time,
325
+ split: idx === 0
326
+ ? split.time
327
+ : split.time - runner.splits[idx - 1].time,
325
328
  });
326
329
  }
327
330
  });
@@ -346,7 +349,7 @@ function defineLegProperties(legs) {
346
349
  return r1.split - r2.split;
347
350
  });
348
351
  // calculate the ideal time: take up to 5 fastest on that leg
349
- var selected = leg.runners.filter((runner) => !isNaN(runner.split) && runner.split !== undefined)
352
+ var selected = leg.runners
350
353
  .slice(0, Math.min(leg.runners.length, 5))
351
354
  .map(function (runner) { return runner.split; });
352
355
  // only if there are valid splits for this leg
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasifix/orienteering-utils",
3
- "version": "2.0.23",
3
+ "version": "2.0.25",
4
4
  "description": "utility functions for orienteering result analyzis",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",