sql first refactor
This commit is contained in:
20
db/routines/R__fn_modbus_written_command_ids.sql
Normal file
20
db/routines/R__fn_modbus_written_command_ids.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
create or replace function ems.fn_modbus_written_command_ids(
|
||||
p_site_id int,
|
||||
p_lookback interval
|
||||
)
|
||||
returns jsonb
|
||||
language sql
|
||||
stable
|
||||
as $fn$
|
||||
select coalesce(
|
||||
jsonb_agg(mc.id order by mc.written_at),
|
||||
'[]'::jsonb
|
||||
)
|
||||
from ems.modbus_command mc
|
||||
where mc.site_id = p_site_id
|
||||
and mc.status = 'written'
|
||||
and mc.written_at >= now() - p_lookback;
|
||||
$fn$;
|
||||
|
||||
comment on function ems.fn_modbus_written_command_ids(int, interval) is
|
||||
'ID written příkazů k ruční verifikaci (GET control/verify).';
|
||||
Reference in New Issue
Block a user