From 36bbc6cfa2135eeaf0efd06c4806bb186b1da982 Mon Sep 17 00:00:00 2001 From: Laura Thomson Date: Wed, 3 Apr 2013 20:30:04 -0400 Subject: [PATCH] Don't add negative values to the start times since they break things (fixes bug 856846) --- js/data.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/js/data.js b/js/data.js index 62b1d00..d48a7e4 100644 --- a/js/data.js +++ b/js/data.js @@ -233,7 +233,7 @@ getAllStartupTimes = function(median) { startupTimeMedian = 0; for(paintTime in paintTimes) { - if(paintTimes.hasOwnProperty(paintTime)) { + if(paintTimes.hasOwnProperty(paintTime) && paintTimes[paintTime]>0) { startupTimesTotal = startupTimesTotal + paintTimes[paintTime]; } } @@ -243,11 +243,15 @@ getAllStartupTimes = function(median) { } else { // This day only has one session, convert to seconds, no need to calculate // a median. - graphData.startupTimes.push([new Date(currentDay).getTime(), paintTimes[paintTime] / 1000]); + if (paintTimes[paintTime]>0) { + graphData.startupTimes.push([new Date(currentDay).getTime(), paintTimes[paintTime] / 1000]); + } } } else { for(paintTime in paintTimes) { - graphData.startupTimes.push([new Date(currentDay).getTime(), paintTimes[paintTime] / 1000]); + if (paintTimes[paintTime]>0) { + graphData.startupTimes.push([new Date(currentDay).getTime(), paintTimes[paintTime] / 1000]); + } } } } @@ -255,12 +259,14 @@ getAllStartupTimes = function(median) { } var latest = new Date().getTime(); // Add one more for the current day. - graphData.dateCount = graphData.dateCount + 1; - // Add the current session's startup time to the end of the array - graphData.startupTimes.push([ - latest, - payload.data.last['org.mozilla.appSessions.current'].firstPaint / 1000 - ]); + if (payload.data.last['org.mozilla.appSessions.current'].firstPaint > 0) { + graphData.dateCount = graphData.dateCount + 1; + // Add the current session's startup time to the end of the array + graphData.startupTimes.push([ + latest, + payload.data.last['org.mozilla.appSessions.current'].firstPaint / 1000 + ]); + } return graphData; }, @@ -288,8 +294,10 @@ calculateMedianStartupTime = function() { // and ensure that we have paint times to add. if(counter < 10 && typeof paintTimes !== 'undefined') { for(var paintTime in paintTimes) { - startupTimes.push(paintTimes[paintTime]); - ++counter; + if (paintTime > 0) { + startupTimes.push(paintTimes[paintTime]); + ++counter; + } } } }