-- Enable required extensions for cron jobs and HTTP requests
create extension if not exists pg_cron;
create extension if not exists pg_net;

-- Schedule the sync-analysis-results job to run every 15 minutes
select
  cron.schedule(
    'sync-analysis-results-every-15-minutes', -- Unique job name
    '*/15 * * * *', -- Cron schedule: every 15 minutes
    $$
    select
      net.http_post(
        url := 'https://test.medreport.ee/api/job/sync-analysis-results',
        headers := jsonb_build_object(
          'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
        )
      ) as request_id;
    $$
  );
