Formatting
This commit is contained in:
parent
c4037f95e9
commit
e58be64dee
@ -23,43 +23,42 @@ var processor = {
|
|||||||
return race;
|
return race;
|
||||||
},
|
},
|
||||||
|
|
||||||
getEnhancedLapDataPerDriver: function(raceData) {
|
getEnhancedLapDataPerDriver: function(raceData) {
|
||||||
var result = [];
|
var result = [];
|
||||||
raceData.drivers.forEach((driver) => {
|
raceData.drivers.forEach((driver) => {
|
||||||
var lapData = {
|
var lapData = {
|
||||||
driver: null,
|
driver: null,
|
||||||
laps: [],
|
laps: [],
|
||||||
};
|
};
|
||||||
lapData.driver = driver;
|
lapData.driver = driver;
|
||||||
//Attach Qualifying Data
|
//Attach Qualifying Data
|
||||||
lapData.qualifying = processor.getQualifyingForDriver(raceData, driver);
|
lapData.qualifying = processor.getQualifyingForDriver(raceData, driver);
|
||||||
//add Qualifying Data to the Laps
|
//add Qualifying Data to the Laps
|
||||||
var lap0 = {'driverId': driver.driverId, 'lap': 0, 'position': lapData.qualifying.position};
|
var lap0 = {'driverId': driver.driverId, 'lap': 0, 'position': lapData.qualifying.position};
|
||||||
var endResult = raceData.results.filter(res => res.driverId == driver.driverId && res.laps == 0);
|
var endResult = raceData.results.filter(res => res.driverId == driver.driverId && res.laps == 0);
|
||||||
if(endResult.length > 0){
|
if(endResult.length > 0){
|
||||||
lap0.finished = endResult[0];
|
lap0.finished = endResult[0];
|
||||||
}
|
}
|
||||||
lapData.laps.push(lap0);
|
lapData.laps.push(lap0);
|
||||||
raceData.lapTimes.forEach(lap => {
|
raceData.lapTimes.forEach(lap => {
|
||||||
lap.forEach(curLap => {
|
lap.forEach(curLap => {
|
||||||
if( curLap.driverId == driver.driverId ){
|
if( curLap.driverId == driver.driverId ){
|
||||||
var pitstop = raceData.pitStops.filter(pitstop => pitstop.driverId == driver.driverId && pitstop.lap == curLap.lap);
|
var pitstop = raceData.pitStops.filter(pitstop => pitstop.driverId == driver.driverId && pitstop.lap == curLap.lap);
|
||||||
var endResult = raceData.results.filter(res => res.driverId == driver.driverId && res.laps == curLap.lap);
|
var endResult = raceData.results.filter(res => res.driverId == driver.driverId && res.laps == curLap.lap);
|
||||||
if(pitstop.length > 0){
|
if(pitstop.length > 0){
|
||||||
curLap.pitStop = pitstop[0];
|
curLap.pitStop = pitstop[0];
|
||||||
}
|
}
|
||||||
if(endResult.length > 0){
|
if(endResult.length > 0){
|
||||||
curLap.finished = endResult[0];
|
curLap.finished = endResult[0];
|
||||||
}
|
}
|
||||||
|
lapData.laps.push(curLap);
|
||||||
lapData.laps.push(curLap);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
result.push(lapData);
|
||||||
result.push(lapData);
|
});
|
||||||
});
|
return result;
|
||||||
return result;
|
},
|
||||||
},
|
|
||||||
|
|
||||||
getRacesByYear: function(year) {
|
getRacesByYear: function(year) {
|
||||||
var races = queries.getRacesByYear(year);
|
var races = queries.getRacesByYear(year);
|
||||||
|
Loading…
Reference in New Issue
Block a user