@rasifix/orienteering-utils 2.0.6 → 2.0.7
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/model/index.d.ts +1 -2
- package/lib/model/ranking.d.ts +0 -19
- package/lib/utils/ranking.d.ts +16 -11
- package/lib/utils/ranking.js +1 -3
- package/package.json +1 -1
package/lib/model/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Category } from './category';
|
|
2
2
|
import { Competition } from './competition';
|
|
3
|
-
import { Ranking, Leg, RankingEntry, RunnerInfo } from './ranking';
|
|
4
3
|
import { Runner, Sex } from './runner';
|
|
5
4
|
import { Split } from './split';
|
|
6
|
-
export { Category, Competition,
|
|
5
|
+
export { Category, Competition, Runner, Sex, Split };
|
package/lib/model/ranking.d.ts
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
export interface Ranking {
|
|
2
|
-
runners: {
|
|
3
|
-
[key: string]: RunnerInfo;
|
|
4
|
-
};
|
|
5
|
-
legs: {
|
|
6
|
-
[key: string]: Leg;
|
|
7
|
-
};
|
|
8
|
-
ranking: RankingEntry[];
|
|
9
|
-
}
|
|
10
|
-
export interface Leg {
|
|
11
|
-
from: string;
|
|
12
|
-
to: string;
|
|
13
|
-
ranking: RankingEntry[];
|
|
14
|
-
}
|
|
15
|
-
export interface RankingEntry {
|
|
16
|
-
rank: number;
|
|
17
|
-
time: string;
|
|
18
|
-
runnerRef: string;
|
|
19
|
-
}
|
|
20
1
|
export interface RunnerInfo {
|
|
21
2
|
fullName: string;
|
|
22
3
|
club: string;
|
package/lib/utils/ranking.d.ts
CHANGED
|
@@ -28,6 +28,11 @@ export interface RunnerLegEntry {
|
|
|
28
28
|
leg?: string;
|
|
29
29
|
position?: number;
|
|
30
30
|
}
|
|
31
|
+
export interface Ranking {
|
|
32
|
+
courses: Course[];
|
|
33
|
+
runners: RankingRunner[];
|
|
34
|
+
legs: RunnerLeg[];
|
|
35
|
+
}
|
|
31
36
|
interface RankingRunner {
|
|
32
37
|
id: string;
|
|
33
38
|
rank?: number;
|
|
@@ -49,6 +54,16 @@ interface RankingSplit {
|
|
|
49
54
|
position: number;
|
|
50
55
|
weight: number | undefined;
|
|
51
56
|
}
|
|
57
|
+
export interface Leg {
|
|
58
|
+
from: string;
|
|
59
|
+
to: string;
|
|
60
|
+
ranking: RankingEntry[];
|
|
61
|
+
}
|
|
62
|
+
export interface RankingEntry {
|
|
63
|
+
rank: number;
|
|
64
|
+
time: string;
|
|
65
|
+
runnerRef: string;
|
|
66
|
+
}
|
|
52
67
|
interface RankingInfo {
|
|
53
68
|
rank?: number;
|
|
54
69
|
behind?: number;
|
|
@@ -57,15 +72,5 @@ interface RankingInfo {
|
|
|
57
72
|
interface SplitInfo extends RankingInfo {
|
|
58
73
|
performanceIndex?: number;
|
|
59
74
|
}
|
|
60
|
-
export declare function parseRanking(runners: Runner[]):
|
|
61
|
-
courses: Course[];
|
|
62
|
-
runners: RankingRunner[];
|
|
63
|
-
legs: {
|
|
64
|
-
code: string;
|
|
65
|
-
spread: [number, number];
|
|
66
|
-
idealSplit: number;
|
|
67
|
-
fastestSplit: number;
|
|
68
|
-
weight: number;
|
|
69
|
-
}[];
|
|
70
|
-
};
|
|
75
|
+
export declare function parseRanking(runners: Runner[]): Ranking;
|
|
71
76
|
export {};
|
package/lib/utils/ranking.js
CHANGED
|
@@ -69,7 +69,6 @@ function parseRanking(runners) {
|
|
|
69
69
|
.map(function (code) { return legs[code].idealSplit; })
|
|
70
70
|
.filter(function (time) { return time !== undefined; })
|
|
71
71
|
.reduce(sum);
|
|
72
|
-
console.log("ideal time: ", idealTime);
|
|
73
72
|
// each leg's weight is calculated regarding as a ratio of the ideal split time to the ideal time
|
|
74
73
|
Object.keys(legs).forEach(function (code) {
|
|
75
74
|
var leg = legs[code];
|
|
@@ -177,14 +176,12 @@ function parseRanking(runners) {
|
|
|
177
176
|
});
|
|
178
177
|
// calculate the overall rank
|
|
179
178
|
rank(rankingRunners);
|
|
180
|
-
console.log(rankingRunners[0].fullName, rankingRunners[0].splits[rankingRunners[0].splits.length - 1]);
|
|
181
179
|
Object.values(legs).forEach(function (leg) {
|
|
182
180
|
var ideal = leg.idealSplit;
|
|
183
181
|
var min = leg.runners.filter(function (runner) { return !isNaN(runner.split) && runner.split !== undefined; }).map(function (runner) { return runner.split; }).reduce(function (min, split) { return Math.min(min, split - ideal); }, Number.MAX_VALUE);
|
|
184
182
|
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);
|
|
185
183
|
leg.spread = [min, max];
|
|
186
184
|
});
|
|
187
|
-
console.log("leg runner", legs[Object.keys(legs)[1]].runners[1]);
|
|
188
185
|
return {
|
|
189
186
|
courses: courses,
|
|
190
187
|
runners: rankingRunners,
|
|
@@ -194,6 +191,7 @@ function parseRanking(runners) {
|
|
|
194
191
|
idealSplit: leg.idealSplit,
|
|
195
192
|
fastestSplit: leg.fastestSplit,
|
|
196
193
|
weight: leg.weight,
|
|
194
|
+
runners: leg.runners
|
|
197
195
|
}); }),
|
|
198
196
|
};
|
|
199
197
|
}
|