fleetmap-reports 1.0.706 → 1.0.707

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.706",
3
+ "version": "1.0.707",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/util/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const { devicesToProcess } = require('./device')
2
+ const { isClientSide } = require('./utils')
2
3
 
3
4
  exports.processServerSide = (userData) => {
4
5
  const devices = devicesToProcess(userData)
5
- return devices.length > 100 && !userData.reportServer
6
+ return devices.length > 100 && isClientSide()
6
7
  }
@@ -75,7 +75,7 @@ async function createZoneReport (from, to, userData, traccar) {
75
75
  deviceCount, devices.length, sliceSize, deviceChunk, undefined)
76
76
 
77
77
  const route = filterPositions(data.route)
78
- const alerts = getInAndOutEvents(slice, route, userData)
78
+ const alerts = await getInAndOutEvents(slice, route, userData)
79
79
 
80
80
  allData.devices.push(...await processDevices(from, to, devices, userData, { alerts, route }))
81
81
 
@@ -300,11 +300,11 @@ function analyseAlerts (alerts, deviceRoute, userData, from, to) {
300
300
  return zoneInOutData
301
301
  }
302
302
 
303
- function getInAndOutEvents (devices, route, userData) {
303
+ async function getInAndOutEvents (devices, route, userData) {
304
304
  const events = []
305
305
  const geofencesFeatures = userData.geofences.map(g => convertToFeature(g))
306
306
 
307
- devices.forEach(d => {
307
+ await Promise.all(devices.map(async d => {
308
308
  const deviceRoute = route.filter(p => p.deviceId === d.id)
309
309
  const routePoints = deviceRoute.sort(sortPositions).map(p => convertPositionToFeature(p))
310
310
  const deviceEvents = []
@@ -336,7 +336,7 @@ function getInAndOutEvents (devices, route, userData) {
336
336
  })
337
337
  })
338
338
  events.push(...deviceEvents)
339
- })
339
+ }))
340
340
  return events
341
341
  }
342
342