Some checks failed
/ build (map[dockerfile:./services/tasks/Dockerfile name:tasks]) (push) Failing after 1m25s
/ deploy (push) Has been skipped
/ build (map[dockerfile:./services/files/Dockerfile name:files]) (push) Failing after 1m34s
/ build (map[dockerfile:./services/app/Dockerfile name:app]) (push) Successful in 2m9s
/ build (map[dockerfile:./services/api/Dockerfile name:api]) (push) Failing after 1m42s
/ build (map[dockerfile:./services/web/Dockerfile name:web]) (push) Failing after 1m18s
/ build (map[dockerfile:./services/watchers/Dockerfile name:watchers]) (push) Failing after 1m22s
/ build (map[dockerfile:./services/hasura/Dockerfile name:hasura]) (push) Successful in 2m3s
29 lines
847 B
PL/PgSQL
29 lines
847 B
PL/PgSQL
CREATE OR REPLACE FUNCTION public.increment_alerting_count()
|
|
RETURNS trigger
|
|
LANGUAGE plpgsql
|
|
AS $function$
|
|
BEGIN
|
|
IF NEW.reason = 'relative' THEN
|
|
UPDATE alert
|
|
SET alerting_relative_count = alerting_relative_count + 1
|
|
WHERE id = NEW.alert_id;
|
|
ELSIF NEW.reason IN ('agent', 'connect') THEN
|
|
UPDATE alert
|
|
SET alerting_connect_count = alerting_connect_count + 1
|
|
WHERE id = NEW.alert_id;
|
|
ELSIF NEW.reason = 'around' THEN
|
|
UPDATE alert
|
|
SET alerting_around_count = alerting_around_count + 1
|
|
WHERE id = NEW.alert_id;
|
|
ELSIF NEW.reason = 'self' THEN
|
|
-- Do nothing for 'self'
|
|
NULL;
|
|
END IF;
|
|
RETURN NEW;
|
|
END;
|
|
$function$;
|
|
|
|
CREATE TRIGGER update_alerting_counts
|
|
AFTER INSERT ON alerting
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION public.increment_alerting_count();
|