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