diff --git a/src/app/content/poule/poule.component.html b/src/app/content/poule/poule.component.html
index f399cdd..9010411 100644
--- a/src/app/content/poule/poule.component.html
+++ b/src/app/content/poule/poule.component.html
@@ -38,7 +38,9 @@
-
+
diff --git a/src/app/content/poule/poule.component.scss b/src/app/content/poule/poule.component.scss
index 86914ec..95c7a02 100644
--- a/src/app/content/poule/poule.component.scss
+++ b/src/app/content/poule/poule.component.scss
@@ -40,6 +40,11 @@
.resultcell {
font-size: 120%;
}
-.best {
- background-color: forestgreen;
+.timerank0 {
+ color: #1dd21d;
+ font-weight: bolder;
+}
+.timerank1 {
+ color :darkorange;
+ font-weight: bold;
}
diff --git a/src/app/content/poule/poule.component.ts b/src/app/content/poule/poule.component.ts
index 0221610..63c5921 100644
--- a/src/app/content/poule/poule.component.ts
+++ b/src/app/content/poule/poule.component.ts
@@ -14,6 +14,7 @@ export class PouleComponent implements OnInit {
protected teams: any[] = [];
protected times: any[] = [];
+ protected teamtotaltimes: {};
protected maxRaces = 0;
private timesIndexed: {};
@@ -56,7 +57,8 @@ export class PouleComponent implements OnInit {
console.log('loading data.');
// fetch the poule data
- this.championshipService.getTeamsInPoule(this.topmenuService.championship$.value, this.topmenuService.tier$.value, this.topmenuService.poule$.value)
+ this.championshipService.getTeamsInPoule(this.topmenuService.championship$.value, this.topmenuService.tier$.value,
+ this.topmenuService.poule$.value)
.subscribe(val => {
this.teams = val;
@@ -69,11 +71,13 @@ export class PouleComponent implements OnInit {
});
this.maxRaces = maxRaces;
});
- this.championshipService.getTimesInPoule(this.topmenuService.championship$.value, this.topmenuService.tier$.value, this.topmenuService.poule$.value).subscribe(val => {
+ this.championshipService.getTimesInPoule(this.topmenuService.championship$.value, this.topmenuService.tier$.value,
+ this.topmenuService.poule$.value).subscribe(val => {
this.times = val;
// preprocess this array -> map idteam on the laptime array so we can index it using 0..n-1
this.timesIndexed = {};
+ this.teamtotaltimes = {};
this.maxLaps = 0;
this.times.forEach(t => {
if (!this.timesIndexed[t.idteam]) {
@@ -84,10 +88,35 @@ export class PouleComponent implements OnInit {
this.maxLaps = t.laptimesms.length;
}
+ // get the list of times, sorted, for each team
+ if (!this.teamtotaltimes[t.idteam]) {
+ this.teamtotaltimes[t.idteam] = [];
+ }
+ const sum = t.laptimesms.reduce((prev, next) => {
+ return prev + next;
+ });
+ this.teamtotaltimes[t.idteam].push(+(sum + (t.penaltysum * 1000)));
+
// calculate the best two
this.bestTwo[t.idteam] = this.getBestTwo(t.idteam);
});
+ console.log('totaltimes');
+ console.log(this.teamtotaltimes);
+ Object.keys(this.teamtotaltimes).forEach(key => {
+ this.teamtotaltimes[key].sort((a, b) => {
+ if (a < b) {
+ return -1;
+ } else if (a === b) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ );
+ });
+
+
});
}
@@ -160,6 +189,10 @@ export class PouleComponent implements OnInit {
}
}
+ getPenalisedRaceTime(raceNr: number, idTeam: number): number {
+ return this.getRaceTime(raceNr, idTeam) + (this.getPenaltySum(raceNr, idTeam) * 1000);
+ }
+
getRaceTime(raceNr: number, idTeam: number): number {
const time = this.getLapTimes(raceNr, idTeam);
if (!time) {
@@ -201,4 +234,15 @@ export class PouleComponent implements OnInit {
}
}
+ getTimeRank(raceindex, idteam: any) {
+ if (!this.teamtotaltimes) {
+ return -1;
+ }
+ let penalisedRaceTime = this.getPenalisedRaceTime(raceindex, idteam);
+ let indexOf = this.teamtotaltimes[idteam].indexOf(penalisedRaceTime);
+ console.log(penalisedRaceTime + ' ' + indexOf);
+ console.log(this.teamtotaltimes[idteam]);
+ console.log(this.timesIndexed[idteam]);
+ return indexOf;
+ }
}