From 7e64e0cf1871f01a48da059ab9b23ce10d69bd30 Mon Sep 17 00:00:00 2001 From: grabowski Date: Fri, 14 Aug 2026 09:25:39 +0700 Subject: [PATCH] fix: one current river level, not two MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The verdict banner and the P.1 outlook each wrote state.p1Now from a different feed — the banner from the latest measurement, the outlook from current_level on the forecast rows, which carries whatever the model saw at its as_of. Forecasts are precomputed hourly, so the two drifted apart: production showed 1.66 m in the banner and 1.52 m in the outlook directly below it. Harmless at low water; at flood stage two contradictory river levels on one screen undermine the warning. setP1Level() now arbitrates: freshest timestamp wins, and the replay and demo hooks pass force since they deliberately pin a level that is not the live one. The outlook renders the arbitrated value and clamps the shown peak to at least the current level, so a stale forecast can no longer predict a peak below where the river already is. endReplay drops the replayed level so live data re-arbitrates cleanly. Verified against a stub reproducing the exact production conditions (gauge 1.66 at 08:35 vs forecast 1.52 at 08:00): both now read 1.66; a 2.50 m rise against a stale 1.81 m peak renders 2.50/2.50; the 2024 replay still tracks its frames and returns to live on stop. --- src/static/dashboard.html | 50 ++++++++++++++++++++++++++++++++------- tests/test_dashboard.py | 22 +++++++++++++++++ 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/static/dashboard.html b/src/static/dashboard.html index 7e21cac..a7472b6 100644 --- a/src/static/dashboard.html +++ b/src/static/dashboard.html @@ -395,7 +395,7 @@