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