fix: move to completed in one place

This commit is contained in:
Gergo Moricz
2024-08-07 18:49:22 +02:00
parent 457c082ba1
commit 191dfbd9ca
2 changed files with 16 additions and 16 deletions
+15 -15
View File
@@ -141,21 +141,21 @@ const saveJob = async (job: Job, result: any, token: string, mode: string) => {
.eq("job_id", job.id); .eq("job_id", job.id);
if (error) throw new Error(error.message); if (error) throw new Error(error.message);
try { // try {
if (mode === "crawl") { // if (mode === "crawl") {
await job.moveToCompleted(null, token, false); // await job.moveToCompleted(null, token, false);
} else { // } else {
await job.moveToCompleted(result, token, false); // await job.moveToCompleted(result, token, false);
} // }
} catch (error) { // } catch (error) {
// I think the job won't exist here anymore // // I think the job won't exist here anymore
} // }
} else { // } else {
try { // try {
await job.moveToCompleted(result, token, false); // await job.moveToCompleted(result, token, false);
} catch (error) { // } catch (error) {
// I think the job won't exist here anymore // // I think the job won't exist here anymore
} // }
} }
ScrapeEvents.logJobEvent(job, "completed"); ScrapeEvents.logJobEvent(job, "completed");
} catch (error) { } catch (error) {
+1 -1
View File
@@ -51,7 +51,7 @@ const processJobInternal = async (token: string, job: Job) => {
try { try {
const result = await processJob(job, token); const result = await processJob(job, token);
const jobState = await job.getState(); const jobState = await job.getState();
if(jobState !== "completed" && jobState !== "failed"){ if (jobState !== "completed" && jobState !== "failed") {
try{ try{
await job.moveToCompleted(result.docs, token, false); //3rd arg fetchNext await job.moveToCompleted(result.docs, token, false); //3rd arg fetchNext
}catch(e){ }catch(e){