1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Fixed wait page after database rebuild, closes GH-59

This commit is contained in:
Krateng 2020-12-02 20:09:19 +01:00
parent 3de4059f85
commit 7a3ee26c87
3 changed files with 22 additions and 9 deletions

View File

@ -43,7 +43,8 @@ def server_info():
return {
"name":settings.get_settings("NAME"),
"version":version,
"versionstring":".".join(str(n) for n in version)
"versionstring":".".join(str(n) for n in version),
"db_status":dbstatus
}
@ -257,6 +258,7 @@ def import_rulemodule(**keys):
def rebuild(**keys):
log("Database rebuild initiated!")
sync()
dbstatus['rebuildinprogress'] = True
from ..proccontrol.tasks.fixexisting import fix
fix()
global cla, coa

View File

@ -44,6 +44,10 @@ import urllib
dblock = Lock() #global database lock
dbstatus = {
"healthy":False,
"rebuildinprogress":False
}
SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved)
ARTISTS = [] # Format: artist
@ -747,6 +751,9 @@ def start_db():
def build_db():
global dbstatus
dbstatus['healthy'] = False
dbstatus['rebuildinprogress'] = True
log("Building database...")
@ -810,6 +817,9 @@ def build_db():
global ISSUES
ISSUES = check_issues()
dbstatus['healthy'] = True
dbstatus['rebuildinprogress'] = False
log("Database fully built!")

View File

@ -17,7 +17,8 @@
console.log("Probing...");
pending = true;
var xhttp = new XMLHttpRequest();
xhttp.open("GET","/apis/mlj_1/test", true);
xhttp.responseType = 'json';
xhttp.open("GET","/apis/mlj_1/serverinfo", true);
xhttp.onreadystatechange = goback;
xhttp.send();
@ -26,15 +27,15 @@
}
function goback() {
if ((this.readyState == 4) && (this.status == 205)) {
console.log("Not ready yet!");
if ((this.readyState == 4) && (this.status == 200)) {
var response = this.response;
var status = response['db_status'];
console.log(response);
if (status['healthy'] && !status['rebuildinprogress']) {
window.location = "/issues";
}
pending = false;
}
if ((this.readyState == 4) && (this.status == 204)) {
console.log("K");
pending = false;
window.location = "/issues";
}
}
</script>