Added queries to get race information. Added processor function to get all races of an given year

This commit is contained in:
Marcel 2017-12-08 13:50:59 +01:00
parent 3ccffc0134
commit 1c91eab49a
2 changed files with 28 additions and 1 deletions

View File

@ -8,7 +8,8 @@ var processor = {
lapTimes: null, lapTimes: null,
pitStops: null, pitStops: null,
qualifying: null, qualifying: null,
results: null results: null,
raceInfo: null
}; };
race.drivers = queries.getDriversByRaceId(raceId); race.drivers = queries.getDriversByRaceId(raceId);
@ -16,7 +17,13 @@ var processor = {
race.qualifying = queries.getQualifingDataByRaceId(raceId); race.qualifying = queries.getQualifingDataByRaceId(raceId);
race.pitStops = queries.getPitStopsByRaceId(raceId); race.pitStops = queries.getPitStopsByRaceId(raceId);
race.results = queries.getResultsByRaceId(raceId); race.results = queries.getResultsByRaceId(raceId);
race.raceInfo = queries.getRaceById(raceId);
return race; return race;
}, },
getRacesByYear: function(year) {
var races = queries.getRacesByYear(year);
return races.map(race => processor.getRace(race.raceId));
}
}; };

View File

@ -109,6 +109,26 @@ var queries = {
return myMap; return myMap;
}, },
getRaceById: function(raceId){
var rawData = preprocessor.getResults();
return rawData.races[raceId];
},
getRacesByYear: function(year){
var rawData = preprocessor.getResults();
var races = [];
for(var key in rawData.races){
if(rawData.races[key].year == year){
races.push(rawData.races[key]);
}
}
races.sort((o1,o2) => o1["round"] - o2["round"]);
return races;
},
getQualifingDataByRaceId: function(raceId) { getQualifingDataByRaceId: function(raceId) {
var rawData = preprocessor.getResults(); var rawData = preprocessor.getResults();