Changeset View
Changeset View
Standalone View
Standalone View
sql/swh-triggers.sql
-- Asynchronous notification of new content insertions | -- Asynchronous notification of new content insertions | ||||
create function notify_new_content() | create function notify_new_content() | ||||
returns trigger | returns trigger | ||||
language plpgsql | language plpgsql | ||||
as $$ | as $$ | ||||
begin | begin | ||||
perform pg_notify('new_content', json_build_object( | perform pg_notify('new_content', json_build_object( | ||||
'sha1', encode(new.sha1, 'hex'), | 'sha1', encode(new.sha1, 'hex'), | ||||
'sha1_git', encode(new.sha1_git, 'hex'), | 'sha1_git', encode(new.sha1_git, 'hex'), | ||||
'sha256', encode(new.sha256, 'hex') | 'sha256', encode(new.sha256, 'hex'), | ||||
'blake2s256', encode(new.blake2s256, 'hex') | |||||
)::text); | )::text); | ||||
return null; | return null; | ||||
end; | end; | ||||
$$; | $$; | ||||
create trigger notify_new_content | create trigger notify_new_content | ||||
after insert on content | after insert on content | ||||
for each row | for each row | ||||
Show All 21 Lines | |||||
create function notify_new_skipped_content() | create function notify_new_skipped_content() | ||||
returns trigger | returns trigger | ||||
language plpgsql | language plpgsql | ||||
as $$ | as $$ | ||||
begin | begin | ||||
perform pg_notify('new_skipped_content', json_build_object( | perform pg_notify('new_skipped_content', json_build_object( | ||||
'sha1', encode(new.sha1, 'hex'), | 'sha1', encode(new.sha1, 'hex'), | ||||
'sha1_git', encode(new.sha1_git, 'hex'), | 'sha1_git', encode(new.sha1_git, 'hex'), | ||||
'sha256', encode(new.sha256, 'hex') | 'sha256', encode(new.sha256, 'hex'), | ||||
'blake2s256', encode(new.blake2s256, 'hex') | |||||
)::text); | )::text); | ||||
return null; | return null; | ||||
end; | end; | ||||
$$; | $$; | ||||
create trigger notify_new_skipped_content | create trigger notify_new_skipped_content | ||||
after insert on skipped_content | after insert on skipped_content | ||||
for each row | for each row | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |