Prechádzať zdrojové kódy

chore: 优化任务发送

x1ongzhu 1 rok pred
rodič
commit
3f61aa0fe6
2 zmenil súbory, kde vykonal 13 pridanie a 0 odobranie
  1. 9 0
      src/device/device.service.ts
  2. 4 0
      src/task/task.service.ts

+ 9 - 0
src/device/device.service.ts

@@ -143,4 +143,13 @@ export class DeviceService {
             await this.deviceRepository.update(id, { clashProfile: profiles[0] })
             await this.deviceRepository.update(id, { clashProfile: profiles[0] })
         }
         }
     }
     }
+
+    async updateDevices(
+        ids: string[],
+        data: {
+            busy?: boolean
+        }
+    ) {
+        await this.deviceRepository.update(ids, data)
+    }
 }
 }

+ 4 - 0
src/task/task.service.ts

@@ -861,6 +861,10 @@ export class TaskService implements OnModuleInit {
             taskItems.map((i) => i.id),
             taskItems.map((i) => i.id),
             TaskItemStatus.PENDING
             TaskItemStatus.PENDING
         )
         )
+        await this.deviceService.updateDevices(
+            devices.map((d) => d.id),
+            { busy: true }
+        )
         Promise.all(
         Promise.all(
             devices.map(async (device, i) => {
             devices.map(async (device, i) => {
                 const items = taskItems.slice(i * 5, i * 5 + 5)
                 const items = taskItems.slice(i * 5, i * 5 + 5)