programming-in-th / programming.in.th

Site component of programming.in.th
https://programming.in.th
GNU Affero General Public License v3.0
91 stars 33 forks source link

feat: remove update trigger (use rabbitmq) instead #864

Closed ImSoZRious closed 4 months ago

ImSoZRious commented 1 year ago

This query has already been run if you want to undo this, you need to recreate the trigger with this code.

CREATE OR REPLACE FUNCTION public.notify_insert_submission()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
    BEGIN
        perform pg_notify('submit', new.id::text);
        return new;
    END;
$function$;

CREATE OR REPLACE FUNCTION public.notify_update_submission()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
    declare 
    payload text;
    begin
        payload := row_to_json(new.*)::text;
        perform pg_notify('update', payload);
        return new;
    END;
$function$;

CREATE TRIGGER on_update AFTER update ON public.submission FOR EACH ROW EXECUTE FUNCTION notify_update_submission();

CREATE TRIGGER on_submit AFTER insert ON public.submission FOR EACH ROW EXECUTE FUNCTION notify_insert_submission();
vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
programming-in-th ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 5, 2024 7:18am
github-actions[bot] commented 1 year ago

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 1.28% 147 / 11481
🔵 Statements 1.28% 147 / 11481
🔵 Functions 2.25% 4 / 177
🔵 Branches 8.94% 17 / 190
File CoverageNo changed files found.
Generated in workflow #803