Skip to content

Instantly share code, notes, and snippets.

@geobabbler
Created March 31, 2020 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geobabbler/98d8c15cdea6f526d2c9c59d9ac3e567 to your computer and use it in GitHub Desktop.
Save geobabbler/98d8c15cdea6f526d2c9c59d9ac3e567 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION public.jhu_county_watched()
RETURNS trigger AS
$BODY$
DECLARE
BEGIN
PERFORM pg_notify('jhucounty', '{"type": "Feature", "geometry": ' ||
st_asgeojson(NEW.wkb_geometry) ||
',"properties": {"message": "' ||
'update' || '",' ||
'"fips": "' || NEW.fips || '",' ||
'"label": "' || NEW.combined_key || '",' ||
'"confirmed": "' || NEW.confirmed || '",' ||
'"last_update": "' || NEW.last_update || '"' ||
'}}' );
RETURN new;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION public.jhu_county_watched()
OWNER TO postgres;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment