From 015300d0981bbca47a57fe82bd9dc61b4fdc71dc Mon Sep 17 00:00:00 2001 From: golenkovm Date: Fri, 28 Jan 2022 09:58:03 +1100 Subject: [PATCH] Slow down warning bar checkfinished calls (#280) * Slow down warning bar checkfinished calls * Fix coding style after review --- views/warningbar/warningbar.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/views/warningbar/warningbar.js b/views/warningbar/warningbar.js index b5acc8f..92e55b0 100644 --- a/views/warningbar/warningbar.js +++ b/views/warningbar/warningbar.js @@ -56,6 +56,8 @@ var authOutageWarningBar = { }, tickOngoing: function() { + const MINSECS = 60; + if (this.finished) { return; } @@ -78,13 +80,8 @@ var authOutageWarningBar = { xmlhttp.open("GET", this.checkfinishedurl, true); xmlhttp.send(); - var estimatedServerTime = this.servertime + (Date.now() - this.clienttime); - var sleepSeconds = this.stops - estimatedServerTime; // How long to sleep until it stops. - if (sleepSeconds <= 0) { - sleepSeconds = 5; // It should be back, keep checking every 5 seconds. - } else { - sleepSeconds = Math.min(sleepSeconds, (5 * 60)); // Check at least every 5 minutes. - } + // Checking if the site is back online every 4-6 minutes. + var sleepSeconds = 4 * MINSECS + (2 * MINSECS * Math.random()); setTimeout(function() { $this.tickOngoing();