(taskId: number)
| 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( |
no test coverage detected