From 01008ed7bb34e541b0b798da9704e0807528ac82 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 26 Nov 2016 23:15:20 +0100 Subject: [PATCH] Don't retry if it has failed more than five times in a row --- js/pihole/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/pihole/index.js b/js/pihole/index.js index a85ffce4..be6f9487 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -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); + } }); }