Author: croberts
Date: 2012-04-27 15:44:40 +0000 (Fri, 27 Apr 2012)
New Revision: 5348
Modified:
trunk/cumin/resources/app.js
Log:
Turning off automatic updates for charts where the duration is greater than 1 day. The
updates are unnecessary when looking at very long durations.
Modified: trunk/cumin/resources/app.js
===================================================================
--- trunk/cumin/resources/app.js 2012-04-25 16:45:29 UTC (rev 5347)
+++ trunk/cumin/resources/app.js 2012-04-27 15:44:40 UTC (rev 5348)
@@ -427,6 +427,11 @@
return false;
}
+
+var ONE_HOUR = 3600;
+var ONE_DAY = 86400;
+var ONE_MONTH = 2592000;
+var MAX_UPDATE_CHART_DURATION = ONE_DAY;
/*
This block of code sets up the allCharts object which is where all of the
charts will be stored. If a given chart already exists in the allCharts
@@ -457,12 +462,29 @@
function after that data is fetched
*/
drawSingleChart = function(id) {
+ var jsonurl =
$(id).getParent().getElements('a')[chart_href].get('href');
+ var passback = "";
+ allCharts['chartNowTime'] = new Date();
+ wooly.setIntervalUpdate(jsonurl, stathandler, 0, passback, true);
+}
+
+/*
+ * This function handles the automatic updates for each chart. Updates will only happen
+ * for charts that have a duration <= MAX_UPDATE_CHART_DURATION (1 day). Updates will
also only happen
+ * when the "resume updates" button is not showing.
+ */
+updateSingleChart = function(id) {
// if the "resume updates" is displayed, we don't want to do updates.
if($('shock').style.display != "undefined" &&
$('shock').style.display != "block") {
var jsonurl =
$(id).getParent().getElements('a')[chart_href].get('href');
- var passback = "";
- allCharts['chartNowTime'] = new Date();
- wooly.setIntervalUpdate(jsonurl, stathandler, 0, passback, true);
+ chartParams = wooly.session.branch(jsonurl);
+ // for long-duration charts, updating is not particularly useful
+ if(chartParams.duration <= MAX_UPDATE_CHART_DURATION) {
+ var jsonurl =
$(id).getParent().getElements('a')[chart_href].get('href');
+ var passback = "";
+ allCharts['chartNowTime'] = new Date();
+ wooly.setIntervalUpdate(jsonurl, stathandler, 0, passback, true);
+ }
}
}
@@ -470,7 +492,7 @@
This function sets up the timer that will trigger the updating of each chart
*/
startChartMonitor = function(id) {
- setInterval(function() {drawSingleChart(id)}, 10000);
+ allCharts[id].intervalId = setInterval(function() {updateSingleChart(id)}, 10000); //
maybe there needs to be updatesinglechart that will check duration, etc
}
/*
@@ -492,7 +514,6 @@
return true;
}
-
/*
The parseJson function takes the output from cumin and massages it into
something that is useful for the charting library in use (currently jqplot).
Show replies by date