mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Slow down warning bar checkfinished calls (#280)
* Slow down warning bar checkfinished calls * Fix coding style after review
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user