fix: move to completed in one place
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user