implmentace plan guardu
Some checks failed
CI and deploy / migration-check (push) Failing after 17s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-04-19 23:10:25 +02:00
parent d8221e3169
commit e3776226a4
9 changed files with 369 additions and 7 deletions

View File

@@ -1,6 +1,12 @@
-- začátek aktuálního (+offset) 15min slotu v Europe/Prague jako timestamptz (UTC instants)
-- Začátek aktuálního (+offset) 15min slotu v Europe/Prague jako timestamptz (UTC instants).
-- Volitelné p_at (např. job po uzavření slotu); null = now().
create or replace function ems.fn_planning_slot_boundary_prague(p_offset_slots int default 0)
drop function if exists ems.fn_planning_slot_boundary_prague(int);
create or replace function ems.fn_planning_slot_boundary_prague(
p_offset_slots int default 0,
p_at timestamptz default null
)
returns timestamptz
language sql
stable
@@ -13,8 +19,10 @@ as $fn$
)
)::timestamp at time zone 'Europe/Prague'
) + make_interval(mins => coalesce(p_offset_slots, 0) * 15)
from (select now() at time zone 'Europe/Prague' as ts) loc;
from (
select coalesce(p_at, now()) at time zone 'Europe/Prague' as ts
) loc;
$fn$;
comment on function ems.fn_planning_slot_boundary_prague(int) is
'Začátek 15min slotu v časové zóně site provozu (Europe/Prague floor); offset v násobcích 15 min.';
comment on function ems.fn_planning_slot_boundary_prague(int, timestamptz) is
'Začátek 15min slotu (Europe/Prague floor); offset v násobcích 15 min; p_at volitelně místo now().';