MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / abortTask

Method abortTask

js/botasaurus-server-js/src/task-helper.ts:639–657  ·  view source on GitHub ↗
(taskId: number)

Source from the content-addressed store, hash-verified

637 }
638
639 static async abortTask(taskId: number): Promise<number> {
640 const abortableStatuses = [TaskStatus.PENDING, TaskStatus.IN_PROGRESS];
641
642 const task = await db.findOneAsync(
643 { id: taskId },
644 { projection: { id: 1, finished_at: 1, status: 1 } }
645 );
646
647 if (!task || !abortableStatuses.includes(task.status)) {
648 return 0;
649 }
650
651 const updateData: any = { status: TaskStatus.ABORTED };
652 if (task.finished_at === null) {
653 updateData.finished_at = new Date();
654 }
655
656 return this.updateTask(taskId, updateData, abortableStatuses);
657 }
658
659 static async retryTask(taskId: number){
660 return db.updateAsync(

Callers 2

deleteTaskFunction · 0.45
abortTaskFunction · 0.45

Calls 1

updateTaskMethod · 0.95

Tested by

no test coverage detected