From 06751a8e2103cc3e48cd7c0fbeece5144448a964 Mon Sep 17 00:00:00 2001 From: Gergo Moricz Date: Tue, 6 Aug 2024 17:31:20 +0200 Subject: [PATCH] fix(crawl-status): missing partial data after cancel --- apps/api/src/controllers/crawl-status.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/api/src/controllers/crawl-status.ts b/apps/api/src/controllers/crawl-status.ts index 8a7b59e0..bc6de593 100644 --- a/apps/api/src/controllers/crawl-status.ts +++ b/apps/api/src/controllers/crawl-status.ts @@ -23,14 +23,6 @@ export async function crawlStatusController(req: Request, res: Response) { const isCancelled = await (await getWebScraperQueue().client).exists("cancelled:" + req.params.jobId); - if (isCancelled) { - return res.json({ - status: "failed", - data: null, - partial_data: [], - }); - } - let progress = job.progress; if(typeof progress !== 'object') { progress = { @@ -61,14 +53,14 @@ export async function crawlStatusController(req: Request, res: Response) { const jobStatus = await job.getState(); res.json({ - status: jobStatus, + status: isCancelled ? "failed" : jobStatus, // progress: job.progress(), current, current_url, current_step, total, - data: data ? data : null, - partial_data: jobStatus == 'completed' ? [] : partialDocs, + data: data && !isCancelled ? data : null, + partial_data: jobStatus == 'completed' && !isCancelled ? [] : partialDocs, }); } catch (error) { Logger.error(error);