Skip to content

Commit

Permalink
emit config.updated & config.changed events
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Sep 6, 2024
1 parent 38dd091 commit c21c323
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions views/006_config_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,15 @@ FOR EACH ROW
CREATE OR REPLACE FUNCTION insert_config_changes_updates_in_event_queue()
RETURNS TRIGGER AS
$$
DECLARE
event_name TEXT := 'config.changed';
BEGIN
IF TG_OP = 'UPDATE' AND OLD.details = NEW.details THEN
RETURN NEW;
IF NEW.change_type = 'diff' THEN
event_name := 'config.updated';
END IF;

INSERT INTO event_queue(name, properties)
VALUES ('config.updated', jsonb_build_object('id', NEW.config_id))
VALUES (event_name, jsonb_build_object('id', NEW.config_id, 'change_id', NEW.id))
ON CONFLICT (name, properties) DO UPDATE
SET created_at = NOW(), last_attempt = NULL, attempts = 0;

Expand Down

0 comments on commit c21c323

Please sign in to comment.