new site BA81, tuyne forecast
All checks were successful
deploy / deploy (push) Successful in 23s
test / smoke-test (push) Successful in 5s

This commit is contained in:
Dusan Vojacek
2026-04-12 20:11:50 +02:00
parent 015c81a8cb
commit 71d8405cee
6 changed files with 459 additions and 27 deletions

View File

@@ -1009,7 +1009,7 @@ async def get_site_forecast_pv(
rows = await conn.fetch(
"""
SELECT run_id, pv_array_id, interval_start, power_w,
irradiance_wm2, temp_c, pv_array_code
irradiance_wm2, temp_c, pv_array_code, controllable
FROM (
SELECT DISTINCT ON (fpi.interval_start, fpr.pv_array_id)
fpi.run_id,
@@ -1018,7 +1018,8 @@ async def get_site_forecast_pv(
fpi.power_w,
fpi.irradiance_wm2,
fpi.temp_c,
apa.code AS pv_array_code
apa.code AS pv_array_code,
apa.controllable
FROM ems.forecast_pv_interval fpi
JOIN ems.forecast_pv_run fpr ON fpr.id = fpi.run_id
JOIN ems.asset_pv_array apa
@@ -1028,20 +1029,21 @@ async def get_site_forecast_pv(
AND fpr.status = 'ok'
ORDER BY fpi.interval_start, fpr.pv_array_id, fpr.created_at DESC
) latest
ORDER BY pv_array_code, interval_start
ORDER BY controllable DESC, pv_array_code, interval_start
""",
site_id,
d,
)
# pv_a = řiditelná pole (curtailment / Deye), pv_b = neřízená (GEN, …) — sloučí více orientací
pv_a: list[dict[str, Any]] = []
pv_b: list[dict[str, Any]] = []
for r in rows:
item = record_to_dict(r)
code = item.get("pv_array_code")
if code == "pv-a":
item.pop("controllable", None)
if r["controllable"]:
pv_a.append(item)
elif code == "pv-b":
else:
pv_b.append(item)
return {"pv_a": pv_a, "pv_b": pv_b}