working on getting times right
This commit is contained in:
parent
21a17bed4c
commit
59b15ac310
@ -40,3 +40,6 @@
|
||||
.resultcell {
|
||||
font-size: 120%;
|
||||
}
|
||||
.best {
|
||||
background-color: forestgreen;
|
||||
}
|
||||
|
||||
@ -14,8 +14,11 @@ export class PouleComponent implements OnInit {
|
||||
|
||||
protected teams: any[] = [];
|
||||
protected times: any[] = [];
|
||||
|
||||
protected maxRaces = 0;
|
||||
private timesIndexed: {};
|
||||
// these are the best two times for each team, indexed by their id
|
||||
protected bestTwo: {};
|
||||
protected maxLaps = 0;
|
||||
|
||||
constructor(private championshipService: ChampionshipService, private route: ActivatedRoute, private topmenuService: TopmenuService) {
|
||||
@ -48,6 +51,7 @@ export class PouleComponent implements OnInit {
|
||||
private loadData() {
|
||||
this.teams = [];
|
||||
this.times = [];
|
||||
this.bestTwo = {};
|
||||
|
||||
console.log('loading data.');
|
||||
|
||||
@ -79,6 +83,9 @@ export class PouleComponent implements OnInit {
|
||||
if (t.laptimesms.length > this.maxLaps) {
|
||||
this.maxLaps = t.laptimesms.length;
|
||||
}
|
||||
|
||||
// calculate the best two
|
||||
this.bestTwo[t.idteam] = this.getBestTwo(t.idteam);
|
||||
});
|
||||
|
||||
});
|
||||
@ -102,7 +109,7 @@ export class PouleComponent implements OnInit {
|
||||
* Get the best two racetimes (including penalties)
|
||||
* @param idTeam
|
||||
*/
|
||||
getBestTwo(idTeam: number): number[] {
|
||||
private getBestTwo(idTeam: number): number[] {
|
||||
if (!this.timesIndexed) {
|
||||
return null;
|
||||
}
|
||||
@ -146,10 +153,8 @@ export class PouleComponent implements OnInit {
|
||||
* @param idTeam
|
||||
*/
|
||||
getAvgOfBestTwo(idTeam: number) {
|
||||
const bestTwo = this.getBestTwo(idTeam);
|
||||
console.log(idTeam+' '+bestTwo);
|
||||
if (bestTwo && bestTwo.length === 2) {
|
||||
return (bestTwo[0] + bestTwo[1]) / 2;
|
||||
if (this.bestTwo && this.bestTwo[idTeam] && this.bestTwo[idTeam].length === 2) {
|
||||
return (this.bestTwo[idTeam][0] + this.bestTwo[idTeam][1]) / 2;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -195,4 +200,5 @@ export class PouleComponent implements OnInit {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user