create extension if not exists pg_cron;
create extension if not exists pg_net;

select
  cron.schedule(
    'send emails with new unassigned jobs 4x a day', 
    '0 4,9,14,18 * * 1-5', -- Run at 07:00, 12:00, 17:00 and 21:00 (GMT +3) on weekdays only
    $$
    select
      net.http_post(
        url := 'https://test.medreport.ee/api/job/send-open-jobs-emails',
        headers := jsonb_build_object(
          'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
        )
      ) as request_id;
    $$
  );
