fleetmap-reports 1.0.706 → 1.0.708

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.708",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -14,6 +14,7 @@
14
14
  "@turf/distance": "^6.5.0",
15
15
  "@turf/helpers": "^6.5.0",
16
16
  "@turf/point-to-line-distance": "^6.5.0",
17
+ "async": "^3.2.4",
17
18
  "axios": "^0.22.0",
18
19
  "axios-cookiejar-support": "^1.0.1",
19
20
  "docx": "^7.3.0",
@@ -5,6 +5,7 @@ const assert = require('assert')
5
5
  const deviceId = 122575
6
6
  // eslint-disable-next-line no-undef
7
7
  describe('Test_Reports', function () {
8
+ this.timeout(5000000)
8
9
  it('Trip by device', async () => {
9
10
  console.log('trip by device')
10
11
  const report = await getReports()
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,12 @@ 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
+ const async = require('async')
308
+ await async.parallel(devices.map(async.asyncify(async d => {
308
309
  const deviceRoute = route.filter(p => p.deviceId === d.id)
309
310
  const routePoints = deviceRoute.sort(sortPositions).map(p => convertPositionToFeature(p))
310
311
  const deviceEvents = []
@@ -336,7 +337,7 @@ function getInAndOutEvents (devices, route, userData) {
336
337
  })
337
338
  })
338
339
  events.push(...deviceEvents)
339
- })
340
+ })))
340
341
  return events
341
342
  }
342
343