sql first refactor
Some checks failed
CI and deploy / migration-check (push) Successful in 5s
CI and deploy / deploy (push) Failing after 20s

This commit is contained in:
Dusan Vojacek
2026-04-19 20:02:20 +02:00
parent a02e11ee13
commit 93f883f5e0
74 changed files with 6022 additions and 4014 deletions

View File

@@ -0,0 +1,14 @@
create or replace function ems.fn_planning_future_price_days()
returns int
language sql
stable
as $fn$
select count(distinct (mip.interval_start at time zone 'Europe/Prague')::date)::int
from ems.market_interval_price mip
where mip.market_source in ('OTE_CZ', 'OTE_CZ_DAM')
and mip.interval_start >= now()
and mip.interval_start < now() + interval '48 hours';
$fn$;
comment on function ems.fn_planning_future_price_days() is
'Počet kalendářních dní s OTE daty v okně now..now+48h (před spuštěním plánu).';