getting the calculations right
This commit is contained in:
parent
03256d7b64
commit
21a17bed4c
@ -14,6 +14,7 @@ import { ChampionshipComponent } from './championship/championship.component';
|
|||||||
import { ChampionshipselectordialogComponent } from './championshipselectordialog/championshipselectordialog.component';
|
import { ChampionshipselectordialogComponent } from './championshipselectordialog/championshipselectordialog.component';
|
||||||
import { RacetimepipePipe } from './racetimepipe.pipe';
|
import { RacetimepipePipe } from './racetimepipe.pipe';
|
||||||
import { MinutesPipe } from './minutes.pipe';
|
import { MinutesPipe } from './minutes.pipe';
|
||||||
|
import { TimespanComponent } from './timespan/timespan.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -25,7 +26,8 @@ import { MinutesPipe } from './minutes.pipe';
|
|||||||
ChampionshipComponent,
|
ChampionshipComponent,
|
||||||
ChampionshipselectordialogComponent,
|
ChampionshipselectordialogComponent,
|
||||||
RacetimepipePipe,
|
RacetimepipePipe,
|
||||||
MinutesPipe
|
MinutesPipe,
|
||||||
|
TimespanComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|||||||
@ -4,10 +4,10 @@
|
|||||||
<!--top level header: race + race 1 + race 2 + ... + penalty + total + result-->
|
<!--top level header: race + race 1 + race 2 + ... + penalty + total + result-->
|
||||||
<div class="toplevelheader" style="grid-column: 1; grid-row : 1">race</div>
|
<div class="toplevelheader" style="grid-column: 1; grid-row : 1">race</div>
|
||||||
<!--<ng-container *ngFor="let y of ' '.repeat(maxLaps).split(''), let lapindex = index">-->
|
<!--<ng-container *ngFor="let y of ' '.repeat(maxLaps).split(''), let lapindex = index">-->
|
||||||
<!--<div class="toplevelheader" [ngStyle]="{'grid-column': (1+lapindex+1), 'grid-row' : 1}">lap {{lapindex+1}}</div>-->
|
<!--<div class="toplevelheader" [ngStyle]="{'grid-column': (1+lapindex+1), 'grid-row' : 1}">lap {{lapindex+1}}</div>-->
|
||||||
<!--</ng-container>-->
|
<!--</ng-container>-->
|
||||||
<div class="toplevelheader" [ngStyle]="{'grid-column': 2, 'grid-row' : 1}">penalty</div>
|
<div class="toplevelheader" [ngStyle]="{'grid-column': 2, 'grid-row' : 1}">penalty</div>
|
||||||
<div class="toplevelheader" [ngStyle]="{'grid-column': 3, 'grid-row' : 1}">total</div>
|
<div class="toplevelheader" [ngStyle]="{'grid-column': 3, 'grid-row' : 1}">racetijd</div>
|
||||||
<div class="toplevelheader" [ngStyle]="{'grid-column': 4, 'grid-row' : 1}">result</div>
|
<div class="toplevelheader" [ngStyle]="{'grid-column': 4, 'grid-row' : 1}">result</div>
|
||||||
|
|
||||||
|
|
||||||
@ -22,10 +22,10 @@
|
|||||||
<ng-container *ngFor="let y of ' '.repeat(maxRaces).split(''), let raceindex = index">
|
<ng-container *ngFor="let y of ' '.repeat(maxRaces).split(''), let raceindex = index">
|
||||||
<!--also loop over laps: then we're in the right cell-->
|
<!--also loop over laps: then we're in the right cell-->
|
||||||
<!--<ng-container *ngFor="let z of ' '.repeat(maxLaps).split(''), let lapindex = index">-->
|
<!--<ng-container *ngFor="let z of ' '.repeat(maxLaps).split(''), let lapindex = index">-->
|
||||||
<!--add the time -->
|
<!--add the time -->
|
||||||
<!--<div [ngStyle]="{'grid-column':lapindex+2, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">-->
|
<!--<div [ngStyle]="{'grid-column':lapindex+2, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">-->
|
||||||
<!--<span class="timecell">{{getLapTime(team.idteam, raceindex, lapindex)/1000 | number:'1.2-2'}}</span>-->
|
<!--<span class="timecell">{{getLapTime(team.idteam, raceindex, lapindex)/1000 | number:'1.2-2'}}</span>-->
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
<!--</ng-container>-->
|
<!--</ng-container>-->
|
||||||
|
|
||||||
<!--add a race header-->
|
<!--add a race header-->
|
||||||
@ -35,11 +35,12 @@
|
|||||||
|
|
||||||
<!--do a penalty for this race/team combo-->
|
<!--do a penalty for this race/team combo-->
|
||||||
<div class="penaltycell" [ngStyle]="{'grid-column':2, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
<div class="penaltycell" [ngStyle]="{'grid-column':2, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
||||||
<span class="timecell seconds">{{getPenaltySum(raceindex, team.idteam) | number:'1.0-0'}}</span>
|
<!--<span class="timecell seconds">{{getPenaltySum(raceindex, team.idteam)}}</span>-->
|
||||||
|
<app-timespan [theNumber]="getPenaltySum(raceindex, team.idteam)" [theUnit]="'s'"></app-timespan>
|
||||||
</div>
|
</div>
|
||||||
<div class="totalcell" [ngStyle]="{'grid-column':3, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
<div class="totalcell" [ngStyle]="{'grid-column':3, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
||||||
<span class="timecell minutes">{{getRaceTime(raceindex, team.idteam) | minutes}}</span>
|
<app-timespan [theNumber]="getRaceTime(raceindex, team.idteam) | minutes" [theUnit]="'m'"></app-timespan>
|
||||||
<span class="timecell seconds">{{getRaceTimeSeconds(raceindex, team.idteam)}}</span>
|
<app-timespan [theNumber]="getRaceTimeSeconds(raceindex, team.idteam)" [theUnit]="'s'"></app-timespan>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -49,8 +50,8 @@
|
|||||||
<div class="resultcell" [ngStyle]="{'grid-column':4,
|
<div class="resultcell" [ngStyle]="{'grid-column':4,
|
||||||
'grid-row-start':2+(teamindex*(maxRaces+1))+1,
|
'grid-row-start':2+(teamindex*(maxRaces+1))+1,
|
||||||
'grid-row-end': 2+(teamindex*(maxRaces+1))+1+maxRaces}">
|
'grid-row-end': 2+(teamindex*(maxRaces+1))+1+maxRaces}">
|
||||||
<span class="timecell minutes">{{getAvgOfBestTwo(team.idteam) | minutes}}</span>
|
<app-timespan [theNumber]="getAvgOfBestTwo(team.idteam) | minutes" [theUnit]="'m'"></app-timespan>
|
||||||
<span class="timecell seconds">{{((getAvgOfBestTwo(team.idteam)/1000)%60).toFixed(2)}}</span>
|
<app-timespan [theNumber]="((getAvgOfBestTwo(team.idteam)/1000)%60).toFixed(2)" [theUnit]="'s'"></app-timespan>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|||||||
@ -34,3 +34,9 @@
|
|||||||
font-size: 60%;
|
font-size: 60%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.penaltycell {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
.resultcell {
|
||||||
|
font-size: 120%;
|
||||||
|
}
|
||||||
|
|||||||
@ -89,20 +89,20 @@ export class PouleComponent implements OnInit {
|
|||||||
|| !this.timesIndexed[idTeam]
|
|| !this.timesIndexed[idTeam]
|
||||||
|| !this.timesIndexed[idTeam][raceNr]
|
|| !this.timesIndexed[idTeam][raceNr]
|
||||||
|| !this.timesIndexed[idTeam][raceNr].penaltysum) {
|
|| !this.timesIndexed[idTeam][raceNr].penaltysum) {
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
const penaltysum = this.timesIndexed[idTeam][raceNr].penaltysum;
|
const penaltysum = this.timesIndexed[idTeam][raceNr].penaltysum;
|
||||||
if (!penaltysum) {
|
if (!penaltysum) {
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
return penaltysum;
|
return penaltysum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get avg of best two in milliseconds.
|
* Get the best two racetimes (including penalties)
|
||||||
* @param idTeam
|
* @param idTeam
|
||||||
*/
|
*/
|
||||||
getAvgOfBestTwo(idTeam: number) {
|
getBestTwo(idTeam: number): number[] {
|
||||||
if (!this.timesIndexed) {
|
if (!this.timesIndexed) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,6 @@ export class PouleComponent implements OnInit {
|
|||||||
// each time is the total of a race
|
// each time is the total of a race
|
||||||
const teamTimes = this.timesIndexed[idTeam];
|
const teamTimes = this.timesIndexed[idTeam];
|
||||||
|
|
||||||
|
|
||||||
if (!teamTimes || teamTimes.length < 2) {
|
if (!teamTimes || teamTimes.length < 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -119,7 +118,9 @@ export class PouleComponent implements OnInit {
|
|||||||
for (let raceNr = 0; raceNr < this.maxRaces; raceNr++) {
|
for (let raceNr = 0; raceNr < this.maxRaces; raceNr++) {
|
||||||
const raceTime = this.getRaceTime(raceNr, idTeam);
|
const raceTime = this.getRaceTime(raceNr, idTeam);
|
||||||
if (raceTime) {
|
if (raceTime) {
|
||||||
totalTimes.push(raceTime);
|
// ADD THE PENALTY HERE!
|
||||||
|
const items = raceTime + this.getPenaltySum(raceNr, idTeam) * 1000;
|
||||||
|
totalTimes.push(items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +137,22 @@ export class PouleComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// take the two lowest
|
// take the two lowest
|
||||||
return (totalTimes[0] + totalTimes[1]) / 2;
|
totalTimes.splice(2);
|
||||||
|
return totalTimes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get avg of best two in milliseconds.
|
||||||
|
* @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;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getRaceTime(raceNr: number, idTeam: number): number {
|
getRaceTime(raceNr: number, idTeam: number): number {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user