Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix: make playground crawl work

Gergő Móricze3279274f1d5
diff --git a/apps/api/src/controllers/status.ts b/apps/api/src/controllers/status.ts
index 8dccfde36..21a9cf472 100644
--- a/apps/api/src/controllers/status.ts
+++ b/apps/api/src/controllers/status.ts
@@ -2,6 +2,7 @@ import { Request, Response } from "express";
import { Logger } from "../../src/lib/logger";
import { getCrawl, getCrawlJobs } from "../../src/lib/crawl-redis";
import { getScrapeQueue } from "../../src/services/queue-service";
+import { supabaseGetJobById } from "../../src/lib/supabase-jobs";
export async function crawlJobStatusPreviewController(req: Request, res: Response) {
try {
@@ -21,7 +22,19 @@ export async function crawlJobStatusPreviewController(req: Request, res: Respons
// }
// }
- const jobs = await Promise.all(jobIDs.map(x => getScrapeQueue().getJob(x)));
+ const jobs = (await Promise.all(jobIDs.map(async x => {
+ const job = await getScrapeQueue().getJob(x);
+
+ if (process.env.USE_DB_AUTHENTICATION === "true") {
+ const supabaseData = await supabaseGetJobById(job.id);
+
+ if (supabaseData) {
+ job.returnvalue = supabaseData.docs;
+ }
+ }
+
+ return job;
+ }))).sort((a, b) => a.timestamp - b.timestamp);
const jobStatuses = await Promise.all(jobs.map(x => x.getState()));
const jobStatus = sc.cancelled ? "failed" : jobStatuses.every(x => x === "completed") ? "completed" : jobStatuses.some(x => x === "failed") ? "failed" : "active";