From 5a8ca5e687773971b30a07195340bc6d1c46a4d6 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 1 Dec 2017 14:04:32 +0100 Subject: [PATCH] WIP. Adding function to get the lap data by race id --- js/queries.js | 17 +++++++++++++++++ js/util.js | 3 +++ 2 files changed, 20 insertions(+) diff --git a/js/queries.js b/js/queries.js index 41cba7d..c512409 100644 --- a/js/queries.js +++ b/js/queries.js @@ -37,4 +37,21 @@ var queries = { return dataset; }, + /* + * TODO + */ + getLapDataByRaceID: function(raceid) { + var rawData = preprocessor.getResults(); + var raceID = raceid; + var lapTimes = rawData['lapTimes'].filter((val) => {return val['raceId'] == raceID;}); + var groupedLapTimes = {}; + lapTimes.forEach(function(d,i) { + var lapNum = d["lap"]; + var driverId = d["driverId"]; + if(groupedLapTimes[lapNum] === undefined) groupedLapTimes[lapNum] = {}; + groupedLapTimes[lapNum][driverId] = d["milliseconds"]; + }); + return groupedLapTimes; + } + }; diff --git a/js/util.js b/js/util.js index 3deaf50..a9b3555 100644 --- a/js/util.js +++ b/js/util.js @@ -12,6 +12,7 @@ var loadingDialog = { progressItemsDone: 0, // Initialize+Show the loading dialog with a number of items to progress show: function(progressItems = 1) { + console.log("show"); this.progressItems = progressItems; this.progressItemsDone = 0; this._updateProgressBar(); @@ -19,11 +20,13 @@ var loadingDialog = { }, // Function to signal that another item was progressed itemFinished: function() { + this.progressItemsDone++; this._updateProgressBar(); }, // Hide the dialog hide: function() { + console.log("hide"); $(this.id).modal('hide'); }, // Private function to update the progress bar shown