fix BA cutoff
Some checks failed
CI and deploy / migration-check (push) Failing after 13s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-24 16:58:45 +02:00
parent 9d31b19ec6
commit 747a5bed08
5 changed files with 129 additions and 12 deletions

View File

@@ -10,6 +10,7 @@ declare
v_b jsonb;
v_hp jsonb;
v_grid jsonb;
v_market jsonb;
v_veh jsonb;
v_ev jsonb;
v_soc_pct numeric;
@@ -136,6 +137,25 @@ begin
raise exception 'No site_grid_connection for site_id=%', p_site_id;
end if;
select jsonb_build_object(
'purchase_pricing_mode', lower(trim(coalesce(smc.purchase_pricing_mode, 'spot'))),
'sale_pricing_mode', lower(trim(coalesce(smc.sale_pricing_mode, 'spot')))
)
into v_market
from ems.site_market_config smc
where smc.site_id = p_site_id
and smc.valid_to is null
order by smc.valid_from desc
limit 1;
v_market := coalesce(
v_market,
jsonb_build_object(
'purchase_pricing_mode', 'spot',
'sale_pricing_mode', 'spot'
)
);
select coalesce(
jsonb_agg(
jsonb_build_object(
@@ -263,6 +283,7 @@ begin
'battery', v_b,
'heat_pump', v_hp,
'grid', v_grid,
'market', v_market,
'vehicles', v_veh,
'ev_sessions', v_ev,
'soc_wh', v_soc_wh,