Another fix for refresh.
This commit is contained in:
@@ -1196,7 +1196,11 @@ def rewrite_chapter(run_id):
|
|||||||
@app.route('/task_status/<string:task_id>')
|
@app.route('/task_status/<string:task_id>')
|
||||||
@login_required
|
@login_required
|
||||||
def get_task_status(task_id):
|
def get_task_status(task_id):
|
||||||
task_result = huey.result(task_id, peek=True)
|
try:
|
||||||
|
task_result = huey.result(task_id, preserve=True)
|
||||||
|
except Exception as e:
|
||||||
|
# If Huey errors out, report it as a failed task so the UI can react
|
||||||
|
return {"status": "completed", "success": False, "error": str(e)}
|
||||||
|
|
||||||
if task_result is None:
|
if task_result is None:
|
||||||
return {"status": "running"}
|
return {"status": "running"}
|
||||||
|
|||||||
@@ -152,9 +152,18 @@ function submitRefine(event) {
|
|||||||
modal.show();
|
modal.show();
|
||||||
|
|
||||||
refinePollInterval = setInterval(() => {
|
refinePollInterval = setInterval(() => {
|
||||||
fetch(`/task_status/${data.task_id}`).then(r => r.json()).then(status => {
|
fetch(`/task_status/${data.task_id}`)
|
||||||
if (status.status === 'completed') window.location.reload();
|
.then(r => r.json())
|
||||||
});
|
.then(status => {
|
||||||
|
if (status.status === 'completed') {
|
||||||
|
clearInterval(refinePollInterval);
|
||||||
|
if (status.success === false) {
|
||||||
|
alert("Refinement failed: " + (status.error || "Check logs"));
|
||||||
|
}
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(e => console.error(e));
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -646,17 +646,26 @@
|
|||||||
showRefiningModal();
|
showRefiningModal();
|
||||||
|
|
||||||
const pollInterval = setInterval(() => {
|
const pollInterval = setInterval(() => {
|
||||||
fetch(`/task_status/${data.task_id}`).then(r => r.json()).then(status => {
|
fetch(`/task_status/${data.task_id}`)
|
||||||
if (status.status === 'completed') {
|
.then(r => {
|
||||||
clearInterval(pollInterval);
|
if (!r.ok) throw new Error("Server error checking status");
|
||||||
if (status.success) {
|
return r.json();
|
||||||
window.location.href = "/project/{{ project.id }}/bible_comparison";
|
})
|
||||||
} else {
|
.then(status => {
|
||||||
alert("Refinement failed. Please check the logs.");
|
if (status.status === 'completed') {
|
||||||
window.location.reload();
|
clearInterval(pollInterval);
|
||||||
|
if (status.success) {
|
||||||
|
window.location.href = "/project/{{ project.id }}/bible_comparison";
|
||||||
|
} else {
|
||||||
|
alert("Refinement failed: " + (status.error || "Check logs for details."));
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error("Polling error:", err);
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user