Fix historical sync progress reload loop
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
{% if latest_run %}
|
||||
<section id="historicalRunProgress"
|
||||
data-status-url="/tools/accounting/historical-learning/run/{{ latest_run.id }}/status"
|
||||
data-run-status="{{ latest_run.status }}"
|
||||
class="rounded-2xl border border-blue-200 bg-white p-5 shadow-soft">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
@@ -84,6 +85,9 @@ const s=document.getElementById('wsCompany'); if(s){s.addEventListener('change',
|
||||
const box = document.getElementById("historicalRunProgress");
|
||||
if (!box) return;
|
||||
const url = box.dataset.statusUrl;
|
||||
const initialStatus = String(box.dataset.runStatus || "").toLowerCase();
|
||||
const terminalAtLoad = ["completed", "failed", "cancelled"].includes(initialStatus);
|
||||
|
||||
const label = document.getElementById("runProgressLabel");
|
||||
const detail = document.getElementById("runProgressDetail");
|
||||
const meta = document.getElementById("runProgressMeta");
|
||||
@@ -150,7 +154,12 @@ const s=document.getElementById('wsCompany'); if(s){s.addEventListener('change',
|
||||
if (!completedReloaded) window.setTimeout(poll, 3000);
|
||||
}
|
||||
|
||||
// If this page was rendered with an already-terminal latest run,
|
||||
// do not poll it and do not reload. This prevents an endless
|
||||
// Completed -> reload -> Completed -> reload loop.
|
||||
if (!terminalAtLoad) {
|
||||
poll();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
const box = document.getElementById("historicalRunProgress");
|
||||
if (!box) return;
|
||||
const url = box.dataset.statusUrl;
|
||||
const initialStatus = String(box.dataset.runStatus || "").toLowerCase();
|
||||
const terminalAtLoad = ["completed", "failed", "cancelled"].includes(initialStatus);
|
||||
|
||||
const label = document.getElementById("runProgressLabel");
|
||||
const detail = document.getElementById("runProgressDetail");
|
||||
const meta = document.getElementById("runProgressMeta");
|
||||
@@ -201,7 +204,12 @@
|
||||
if (!completedReloaded) window.setTimeout(poll, 3000);
|
||||
}
|
||||
|
||||
// If this page was rendered with an already-terminal latest run,
|
||||
// do not poll it and do not reload. This prevents an endless
|
||||
// Completed -> reload -> Completed -> reload loop.
|
||||
if (!terminalAtLoad) {
|
||||
poll();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user