Files
ems/db/routines/R__077_fn_update_heartbeat.sql
Dusan Vojacek a07f5d57cb
Some checks failed
CI and deploy / migration-check (push) Failing after 10s
CI and deploy / deploy (push) Has been skipped
fix 500
2026-04-20 11:11:47 +02:00

23 lines
856 B
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
create or replace function ems.fn_update_heartbeat(
p_site_id int,
p_status text default 'ok',
p_ems_version text default null
)
returns void
language sql
as $$
insert into ems.site_heartbeat (site_id, last_seen, status, ems_version)
values (p_site_id, now(), p_status, p_ems_version)
on conflict (site_id) do update set
last_seen = now(),
status = excluded.status,
ems_version = coalesce(excluded.ems_version, ems.site_heartbeat.ems_version);
$$;
comment on function ems.fn_update_heartbeat(int, text, text) is
'Aktualizuje informační heartbeat záznam EMS pro danou lokalitu.
Volat každou minutu z backend service po úspěšném odeslání pulzu do Loxone.
Slouží pouze pro EMS dashboard Loxone watchdog nezávisí na této tabulce,
sleduje HTTP pulzy přímo a nezávisle na dostupnosti DB.';