Skip to content

Commit

Permalink
feat: send action payloads on pg notify
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Sep 10, 2024
1 parent 1fb76f7 commit add834f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions views/018_playbooks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
CREATE OR REPLACE FUNCTION notify_playbook_action_update() RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'INSERT' THEN
NOTIFY playbook_action_updates;
PERFORM pg_notify('playbook_action_updates', json_build_object('id', NEW.id, 'agent_id', NEW.agent_id)::TEXT);
ELSEIF TG_OP = 'UPDATE' THEN
IF OLD.status != NEW.status AND NEW.status = 'scheduled' THEN
NOTIFY playbook_action_updates;
PERFORM pg_notify('playbook_action_updates', json_build_object('id', NEW.id, 'agent_id', NEW.agent_id)::TEXT);
END IF;
END IF;

Expand Down

0 comments on commit add834f

Please sign in to comment.