From ff0c65a7944987f2eb8b155706b3bb8643851b62 Mon Sep 17 00:00:00 2001 From: rpotter6298 Date: Sat, 25 Apr 2026 21:03:41 +0200 Subject: [PATCH] Fix weather display: use issued_at for zero-hour truth and deduplicate forecasts - Changed save_zero_hour_forecast_as_truth to use issued_at instead of target_at for resolved_at timestamp - Added window function to deduplicate forecast points, keeping only the most recent for each (target_at, horizon_hours) - Limits resolved truth query to current time to prevent future points from displaying - This fixes vertical lines in the chart caused by duplicate forecasts and ensures truth data displays correctly --- gibil/classes/weather_store.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gibil/classes/weather_store.py b/gibil/classes/weather_store.py index 3c10378..a6db1d8 100644 --- a/gibil/classes/weather_store.py +++ b/gibil/classes/weather_store.py @@ -216,8 +216,20 @@ class WeatherStore: temperature_c, shortwave_radiation_w_m2, cloud_cover_pct - FROM weather_forecast_points - WHERE target_at >= %s AND target_at <= %s + FROM ( + SELECT + issued_at, + target_at, + horizon_hours, + source, + temperature_c, + shortwave_radiation_w_m2, + cloud_cover_pct, + ROW_NUMBER() OVER (PARTITION BY target_at, horizon_hours ORDER BY issued_at DESC) as rn + FROM weather_forecast_points + WHERE target_at >= %s AND target_at <= %s + ) as ranked + WHERE rn = 1 ORDER BY target_at, horizon_hours LIMIT 5000 """,