|
|
@@ -24,7 +24,8 @@ export class TaskService implements OnModuleInit {
|
|
|
private readonly phoneListService: PhoneListService,
|
|
|
private readonly deviceService: DeviceService,
|
|
|
private readonly sysConfigService: SysConfigService
|
|
|
- ) {}
|
|
|
+ ) {
|
|
|
+ }
|
|
|
|
|
|
onModuleInit() {
|
|
|
this.taskRepository.update({ status: TaskStatus.PENDING }, { status: TaskStatus.IDLE })
|
|
|
@@ -65,7 +66,22 @@ export class TaskService implements OnModuleInit {
|
|
|
if ((task && task.status === TaskStatus.IDLE) || task.status === TaskStatus.PAUSE) {
|
|
|
task.status = TaskStatus.PENDING
|
|
|
await this.taskRepository.save(task)
|
|
|
- this.runTask(task)
|
|
|
+ await this.runTask(task)
|
|
|
+
|
|
|
+ const successCount = await this.taskItemRepository.countBy({
|
|
|
+ taskId: id,
|
|
|
+ status: 'success'
|
|
|
+ })
|
|
|
+ const totalCount = await this.taskItemRepository.countBy({
|
|
|
+ taskId: id
|
|
|
+ })
|
|
|
+ if (totalCount === 0) {
|
|
|
+ throw new Error('No tasks found for the given taskId.')
|
|
|
+ }
|
|
|
+ // 计算成功率
|
|
|
+ const successRate = ((successCount / totalCount) * 100).toFixed(1) + '%'
|
|
|
+ task.successRate = String(successRate)
|
|
|
+ await this.taskRepository.save(task)
|
|
|
}
|
|
|
}
|
|
|
|