From e0850680691f465e27551fb027c3c775dde337c0 Mon Sep 17 00:00:00 2001 From: Dusan Vojacek Date: Wed, 22 Apr 2026 19:40:55 +0200 Subject: [PATCH] fix forecast korekce --- backend/app/routers/sites.py | 12 ++++++------ db/routines/R__075_fn_forecast_pv_slots_range.sql | 4 ++-- .../R__079_fn_forecast_pv_slots_range_corrected.sql | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/app/routers/sites.py b/backend/app/routers/sites.py index 640d5c2..85c96b2 100644 --- a/backend/app/routers/sites.py +++ b/backend/app/routers/sites.py @@ -495,15 +495,15 @@ async def get_site_forecast_pv_slots_range( to_ts: datetime = Query( ..., alias="to", - description="Konec polouzavřeného intervalu (max. cca 120 h za from)", + description="Konec polouzavřeného intervalu (max. 60 dní za from)", ), ) -> dict[str, list[dict[str, Any]]]: if to_ts <= from_ts: raise HTTPException(status_code=422, detail="'to' must be after 'from'") - if to_ts - from_ts > timedelta(hours=120): + if to_ts - from_ts > timedelta(days=60): raise HTTPException( status_code=422, - detail="Span between 'from' and 'to' must be at most 120 hours", + detail="Span between 'from' and 'to' must be at most 60 days", ) async with db.acquire() as conn: site_ok = await conn.fetchval( @@ -536,7 +536,7 @@ async def get_site_forecast_pv_slots_range_corrected( to_ts: datetime = Query( ..., alias="to", - description="Konec polouzavřeného intervalu (max. cca 120 h za from)", + description="Konec polouzavřeného intervalu (max. 60 dní za from)", ), delta_from_ts: datetime | None = Query( None, @@ -563,10 +563,10 @@ async def get_site_forecast_pv_slots_range_corrected( ) -> dict[str, list[dict[str, Any]]]: if to_ts <= from_ts: raise HTTPException(status_code=422, detail="'to' must be after 'from'") - if to_ts - from_ts > timedelta(hours=120): + if to_ts - from_ts > timedelta(days=60): raise HTTPException( status_code=422, - detail="Span between 'from' and 'to' must be at most 120 hours", + detail="Span between 'from' and 'to' must be at most 60 days", ) now = datetime.now(tz=timezone.utc) delta_to = delta_to_ts or now diff --git a/db/routines/R__075_fn_forecast_pv_slots_range.sql b/db/routines/R__075_fn_forecast_pv_slots_range.sql index 2ae7ab0..ae47a1f 100644 --- a/db/routines/R__075_fn_forecast_pv_slots_range.sql +++ b/db/routines/R__075_fn_forecast_pv_slots_range.sql @@ -14,7 +14,7 @@ as $fn$ p_from as ts_from, case when p_to <= p_from then p_from + interval '15 minutes' - when p_to > p_from + interval '120 hours' then p_from + interval '120 hours' + when p_to > p_from + interval '60 days' then p_from + interval '60 days' else p_to end as ts_to ), @@ -64,4 +64,4 @@ as $fn$ $fn$; comment on function ems.fn_forecast_pv_slots_range(int, timestamptz, timestamptz) is - 'JSON pole {interval_start, pv_forecast_total_w} po 15 min pro [p_from, p_to); doplnění grafu plánu za hranicí planning_interval.'; + 'JSON pole {interval_start, pv_forecast_total_w} po 15 min pro [p_from, p_to); doplnění grafu plánu za hranicí planning_interval. Horizont je omezený na max. 60 dní.'; diff --git a/db/routines/R__079_fn_forecast_pv_slots_range_corrected.sql b/db/routines/R__079_fn_forecast_pv_slots_range_corrected.sql index c914bd2..f145083 100644 --- a/db/routines/R__079_fn_forecast_pv_slots_range_corrected.sql +++ b/db/routines/R__079_fn_forecast_pv_slots_range_corrected.sql @@ -26,7 +26,7 @@ as $fn$ p_from as ts_from, case when p_to <= p_from then p_from + interval '15 minutes' - when p_to > p_from + interval '120 hours' then p_from + interval '120 hours' + when p_to > p_from + interval '60 days' then p_from + interval '60 days' else p_to end as ts_to ), @@ -120,4 +120,4 @@ as $fn$ $fn$; comment on function ems.fn_forecast_pv_slots_range_corrected(int, timestamptz, timestamptz, timestamptz, timestamptz, numeric, int) is - 'JSON pole {interval_start, pv_forecast_total_w, pv_forecast_corrected_w, slot_of_day} po 15 min pro [p_from, p_to). Korekce je aditivní delta profil z fn_pv_forecast_delta_profile.'; + 'JSON pole {interval_start, pv_forecast_total_w, pv_forecast_corrected_w, slot_of_day} po 15 min pro [p_from, p_to). Korekce je aditivní delta profil z fn_pv_forecast_delta_profile. Horizont je omezený na max. 60 dní.';