fleetmap-reports 1.0.924 → 1.0.925

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/util/utils.js +19 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.924",
3
+ "version": "1.0.925",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/util/utils.js CHANGED
@@ -226,14 +226,25 @@ function weekDaySelected (date, weekDays) {
226
226
 
227
227
  async function executeServerSide (type, allData, sliced, from, to, userData, totalDevices) {
228
228
  let deviceCount = 0
229
- console.log(`PROGRESS_PERC:${1 / totalDevices * 100}`)
230
- await Promise.all(sliced.map(async devices => {
231
- const url = `https://${process.env.SERVER_HOST}/reports/${type}`
232
- const data = await axios.post(url, { from, to, userData: { ...userData, devices } }, { withCredentials: true }).then(d => d.data)
233
- allData.devices.push(...(data[0].devices))
234
- deviceCount = deviceCount + devices.length
235
- console.log(`PROGRESS_PERC:${deviceCount / totalDevices * 100}`)
236
- }))
229
+ console.log('PROGRESS_PERC:1')
230
+ const maxRequests = 4
231
+ for (let i=0; i < sliced.length; i+=maxRequests) {
232
+ const _sliced = sliced.slice(i, i+maxRequests)
233
+ await Promise.all(_sliced.map(async devices => {
234
+ const url = `https://${process.env.SERVER_HOST}/reports/${type}`
235
+ const data = await axios.post(url, {
236
+ from,
237
+ to,
238
+ userData: {
239
+ ...userData,
240
+ devices
241
+ }
242
+ }, { withCredentials: true }).then(d => d.data)
243
+ allData.devices.push(...(data[0].devices))
244
+ deviceCount = deviceCount + devices.length
245
+ console.log(`PROGRESS_PERC:${deviceCount / totalDevices * 100}`)
246
+ }))
247
+ }
237
248
  }
238
249
 
239
250
  exports.executeServerSide = executeServerSide