Oops a Comma and RF Timeout

(cherry picked from commit 1f0b1e2cbc)
This commit is contained in:
dirwin31
2026-08-20 15:28:54 -07:00
committed by firestar5683
parent 931877feb9
commit 0a89eaf255
2 changed files with 26 additions and 9 deletions
@@ -587,6 +587,16 @@ function renderDashboard(state) {
scheduleDashboardRefresh(dashboard);
}
const STATS_ATTEMPT_TIMEOUTS_MS = [5000, 20000];
async function fetchDashboardStats(timeoutMs) {
const statsResponse = await withTimeout(fetch("/api/stats"), timeoutMs, "stats request");
if (!statsResponse.ok) throw new Error(`stats API error: ${statsResponse.status}`);
return withTimeout(statsResponse.json(), timeoutMs, "stats JSON parse");
}
async function initializeHome(force = false) {
if (force) {
clearDashboardRefreshTimer();
@@ -594,20 +604,27 @@ async function initializeHome(force = false) {
renderDashboard(HOME_STATE);
}
try {
const statsResponse = await withTimeout(fetch("/api/stats"), 5000, "stats request");
let statsJson = null;
let lastError = null;
for (const timeoutMs of STATS_ATTEMPT_TIMEOUTS_MS) {
try {
statsJson = await fetchDashboardStats(timeoutMs);
lastError = null;
break;
} catch (err) {
lastError = err;
}
}
if (!statsResponse.ok) throw new Error(`stats API error: ${statsResponse.status}`);
const statsJson = await withTimeout(statsResponse.json(), 5000, "stats JSON parse");
if (lastError) {
HOME_STATE.status = "error";
HOME_STATE.error = lastError?.message || String(lastError);
} else {
const payloadUnit = statsJson?.dashboard?.week?.distanceUnit || statsJson?.driveStats?.all?.unit;
HOME_STATE.data = statsJson;
HOME_STATE.unit = payloadUnit || HOME_STATE.unit || "miles";
HOME_STATE.status = "ready";
} catch (err) {
HOME_STATE.status = "error";
HOME_STATE.error = err?.message || String(err);
}
renderDashboard(HOME_STATE);
+1 -1
View File
@@ -2863,7 +2863,7 @@ def get_dashboard_stats(footage_paths, params_obj=None, now=None):
_DASHBOARD_CACHE.update({
"key": cache_key,
"updated_at": time.monotonic(),,
"updated_at": time.monotonic(),
"value": copy.deepcopy(dashboard),
})
return dashboard