Don't retry if it has failed more than five times in a row

This commit is contained in:
DL6ER
2016-11-26 23:15:20 +01:00
parent 6f8e423c7b
commit 01008ed7bb
+9 -2
View File
@@ -214,6 +214,7 @@ function updateSummaryData(runOnce) {
});;
}
var failures = 0;
function updateQueriesOverTime() {
$.getJSON("api.php?overTimeData10mins", function(data) {
// convert received objects to arrays
@@ -238,10 +239,16 @@ function updateQueriesOverTime() {
timeLineChart.update();
}).done(function() {
// Reload graph after 10 minutes
failures = 0;
setTimeout(updateQueriesOverTime, 600000);
}).fail(function() {
// Try again after 1 minute
setTimeout(updateQueriesOverTime, 60000);
failures++;
if(failures < 5)
{
// Try again after 1 minute only if this has not failed more
// than five times in a row
setTimeout(updateQueriesOverTime, 60000);
}
});
}