fleetmap-reports 1.0.699 → 1.0.700

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/zone-report.js +12 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.699",
3
+ "version": "1.0.700",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@ const axios = require('axios')
15
15
  const { processServerSide } = require('./util')
16
16
  const { filterPositions } = require('./util/route')
17
17
  const { checkGeofenceIn } = require('./util/geofence')
18
- const sliceSize = 400
18
+ const sliceSize = 100
19
19
  const deviceChunk = 5
20
20
  const fileName = 'ZoneReport'
21
21
 
@@ -29,7 +29,17 @@ async function createZoneReport (from, to, userData, traccar) {
29
29
 
30
30
  if (processServerSide(userData)) {
31
31
  const url = `https://${process.env.SERVER_HOST}/reports/zone-report`
32
- return axios.post(url, { from, to, userData }, { withCredentials: true }).then(d => d.data)
32
+ const sliced = automaticReports.sliceArray(devices, sliceSize)
33
+ const promises = []
34
+ for (const slice of sliced) {
35
+ promises.push(axios.post(url, { from, to, userData: { ...userData, devices: slice } }, { withCredentials: true })
36
+ .then(d => d.data)
37
+ .then(data => allData.devices.push(...(data[0].devices)))
38
+ )
39
+ }
40
+ await Promise.all(promises)
41
+ reportData.push(allData)
42
+ return reportData
33
43
  }
34
44
  const types = ['geofenceEnter', 'geofenceExit']
35
45