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
This commit is contained in:
rpotter6298
2026-04-25 21:03:41 +02:00
parent 0814e7c965
commit ff0c65a794
+12
View File
@@ -216,8 +216,20 @@ class WeatherStore:
temperature_c, temperature_c,
shortwave_radiation_w_m2, shortwave_radiation_w_m2,
cloud_cover_pct cloud_cover_pct
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 FROM weather_forecast_points
WHERE target_at >= %s AND target_at <= %s WHERE target_at >= %s AND target_at <= %s
) as ranked
WHERE rn = 1
ORDER BY target_at, horizon_hours ORDER BY target_at, horizon_hours
LIMIT 5000 LIMIT 5000
""", """,