fix forecast korekce
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user