|
@@ -39,8 +39,8 @@ import { Device } from '../device/entities/device.entity'
|
|
|
import Decimal from 'decimal.js'
|
|
import Decimal from 'decimal.js'
|
|
|
import { CountryConfigService } from '../country-config/country-config.service'
|
|
import { CountryConfigService } from '../country-config/country-config.service'
|
|
|
import { TaskResult } from './types'
|
|
import { TaskResult } from './types'
|
|
|
-import { dashboard } from '../rcs-number/impl/dashboard.service'
|
|
|
|
|
-import { smspva } from '../rcs-number/impl/smspva.service'
|
|
|
|
|
|
|
+
|
|
|
|
|
+export const batchSize = 10
|
|
|
|
|
|
|
|
@Injectable()
|
|
@Injectable()
|
|
|
export class TaskService implements OnModuleInit {
|
|
export class TaskService implements OnModuleInit {
|
|
@@ -1277,7 +1277,7 @@ export class TaskService implements OnModuleInit {
|
|
|
|
|
|
|
|
// devices.forEach((device) => {
|
|
// devices.forEach((device) => {
|
|
|
// let candidateTasks = res.filter(
|
|
// let candidateTasks = res.filter(
|
|
|
- // (r) => Math.ceil((r.task.total - r.task.sent) / 5) > r.devices.length
|
|
|
|
|
|
|
+ // (r) => Math.ceil((r.task.total - r.task.sent) / batchSize) > r.devices.length
|
|
|
// )
|
|
// )
|
|
|
// if (device.matchCountry && device.pinCountry) {
|
|
// if (device.matchCountry && device.pinCountry) {
|
|
|
// candidateTasks = candidateTasks.filter((r) => {
|
|
// candidateTasks = candidateTasks.filter((r) => {
|
|
@@ -1431,7 +1431,7 @@ export class TaskService implements OnModuleInit {
|
|
|
taskId: task.id,
|
|
taskId: task.id,
|
|
|
status: TaskItemStatus.IDLE
|
|
status: TaskItemStatus.IDLE
|
|
|
},
|
|
},
|
|
|
- take: devices.length * 5
|
|
|
|
|
|
|
+ take: devices.length * batchSize
|
|
|
})
|
|
})
|
|
|
if (taskItems.length === 0) {
|
|
if (taskItems.length === 0) {
|
|
|
return
|
|
return
|
|
@@ -1441,7 +1441,7 @@ export class TaskService implements OnModuleInit {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- devices = devices.splice(0, Math.ceil(taskItems.length / 5))
|
|
|
|
|
|
|
+ devices = devices.splice(0, Math.ceil(taskItems.length / batchSize))
|
|
|
const taskConfig = {
|
|
const taskConfig = {
|
|
|
singleQty: task.singleQty || (await this.getConfig('single_qty', 1)),
|
|
singleQty: task.singleQty || (await this.getConfig('single_qty', 1)),
|
|
|
singleTimeout: task.singleTimeout || (await this.getConfig('single_timeout', 2000)),
|
|
singleTimeout: task.singleTimeout || (await this.getConfig('single_timeout', 2000)),
|
|
@@ -1469,7 +1469,7 @@ export class TaskService implements OnModuleInit {
|
|
|
Promise.all(
|
|
Promise.all(
|
|
|
devices.map(async (device, i) => {
|
|
devices.map(async (device, i) => {
|
|
|
const items = taskItems
|
|
const items = taskItems
|
|
|
- .slice(i * 5, i * 5 + 5)
|
|
|
|
|
|
|
+ .slice(i * batchSize, i * batchSize + batchSize)
|
|
|
.map((item) => ({ ...item, message: this.getMessage(task), img: task.img }))
|
|
.map((item) => ({ ...item, message: this.getMessage(task), img: task.img }))
|
|
|
if (items.length === 0) return
|
|
if (items.length === 0) return
|
|
|
try {
|
|
try {
|