Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IQSS/11264 - Add pseudo-exponential backoff to dataset page refresh #11269

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When a dataset has a long running lock, including when it is 'in review', Dataverse will now slow the page refresh rate over time.
15 changes: 12 additions & 3 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,11 @@
$(this).ready(function () {
refreshIfStillLocked();
});

var initialInterval = 5000; // 5 seconds
var maxInterval = 300000; // 5 minutes
var currentInterval = initialInterval;
var backoffFactor = 1.2; // Exponential factor
function refreshIfStillLocked() {
if ($('input[id$="datasetLockedForAnyReasonVariable"]').val() === 'true') {
// if dataset is locked, instruct the page to
Expand All @@ -882,18 +887,22 @@
$('button[id$="refreshButton"]').trigger('click');
//refreshAllCommand();
}, 1500);
} else {
// Reset the interval if the dataset is unlocked
currentInterval = initialInterval;
}
}
}

function waitAndCheckLockAgain() {
setTimeout(function () {
// refresh the lock in the
// backing bean; i.e., check, if the ingest has
// already completed in the background:
//$('button[id$="refreshButton"]').trigger('click');
//refreshLockCommand();
refreshAllLocksCommand();
}, 10000);
// Increase the interval exponentially for the next check
currentInterval = Math.min((currentInterval * backoffFactor) + 2, maxInterval);
}, currentInterval);
}
//]]>
</script>
Expand Down