fleetmap-reports 2.0.232 → 2.0.233
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.
- package/package.json +1 -1
- package/src/zone-report.js +4 -3
package/package.json
CHANGED
package/src/zone-report.js
CHANGED
|
@@ -25,8 +25,8 @@ const axios = require('axios').default
|
|
|
25
25
|
const sliceSize = 1
|
|
26
26
|
const deviceChunk = 5
|
|
27
27
|
const fileName = 'ZoneReport'
|
|
28
|
-
const {pLimit} = require('p-limit')
|
|
29
|
-
|
|
28
|
+
const { pLimit } = require('p-limit')
|
|
29
|
+
const limit = pLimit(50)
|
|
30
30
|
|
|
31
31
|
exports.process = async (traccar, from, to, slice, deviceCount, devices, reportRangeDays, userData) => {
|
|
32
32
|
const data = await traccarHelper.getAllInOne(
|
|
@@ -87,7 +87,7 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
87
87
|
|
|
88
88
|
const url = 'https://api.pinme.io/pinmeapi/process-report/zone-report-processing'
|
|
89
89
|
|
|
90
|
-
const promises = sliced.map((slice, i) => {
|
|
90
|
+
const promises = sliced.map((slice, i) => limit(async () => {
|
|
91
91
|
const now = new Date()
|
|
92
92
|
return traccar.axios.post(url, {
|
|
93
93
|
from,
|
|
@@ -102,6 +102,7 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
102
102
|
return response.data
|
|
103
103
|
}).catch(e => console.error(url, e.message, e))
|
|
104
104
|
})
|
|
105
|
+
)
|
|
105
106
|
const results = await Promise.all(promises)
|
|
106
107
|
results.forEach(processed => {
|
|
107
108
|
if (processed) {
|