diff --git a/apps/api/src/lib/supabase-jobs.ts b/apps/api/src/lib/supabase-jobs.ts index b4247883..8ff46a23 100644 --- a/apps/api/src/lib/supabase-jobs.ts +++ b/apps/api/src/lib/supabase-jobs.ts @@ -1,10 +1,12 @@ import { supabase_service } from "../services/supabase"; +import { Logger } from "./logger"; +import * as Sentry from "@sentry/node"; export const supabaseGetJobById = async (jobId: string) => { const { data, error } = await supabase_service - .from('firecrawl_jobs') - .select('*') - .eq('job_id', jobId) + .from("firecrawl_jobs") + .select("*") + .eq("job_id", jobId) .single(); if (error) { @@ -16,15 +18,16 @@ export const supabaseGetJobById = async (jobId: string) => { } return data; -} +}; export const supabaseGetJobsById = async (jobIds: string[]) => { - const { data, error } = await supabase_service - .from('firecrawl_jobs') - .select('*') - .in('job_id', jobIds); + const { data, error } = await supabase_service.rpc("get_jobs_by_ids", { + job_ids: jobIds, + }); if (error) { + Logger.error(`Error in get_jobs_by_ids: ${error}`); + Sentry.captureException(error); return []; } @@ -33,5 +36,4 @@ export const supabaseGetJobsById = async (jobIds: string[]) => { } return data; -} - +};