fleetmap-reports 1.0.408 → 1.0.409

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 +13 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.408",
3
+ "version": "1.0.409",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -30,7 +30,7 @@ async function createZoneReport (from, to, userData, traccar) {
30
30
  group: g,
31
31
  xpert: devices.filter(d => d.attributes.xpert).length > 0
32
32
  }
33
-
33
+ console.log('LOADING_MESSAGE:' + 'Eventos...')
34
34
  const response = await traccar.reports.reportsEventsGet(from, to, null, [g.id], types)
35
35
  const data = response.data
36
36
 
@@ -56,21 +56,24 @@ async function createZoneReport (from, to, userData, traccar) {
56
56
  const sliced = automaticReports.sliceArray(devices, 50)
57
57
 
58
58
  let deviceCount = 0
59
+ const promises = []
59
60
  for (const slice of sliced) {
60
- const allInOne = await traccarHelper.getAllInOne(
61
+ promises.push(traccarHelper.getAllInOne(
61
62
  traccar, from, to, slice, true, false, false, false,
62
- deviceCount, devices.length, 30, 10)
63
- const routeData = allInOne.route
63
+ deviceCount, devices.length, 30, 5).then(async allInOne => {
64
+ const routeData = allInOne.route
64
65
 
65
- const data = getInAndOutEvents(slice, routeData, userData)
66
+ const data = getInAndOutEvents(slice, routeData, userData)
66
67
 
67
- console.log('Geofence Enter/Exit Alerts:' + data.length)
68
+ console.log('Geofence Enter/Exit Alerts:' + data.length)
68
69
 
69
- if (data.length) {
70
- allData.devices.push(...await processDevices(from, to, devices, userData.drivers, userData.geofences, data, traccar))
71
- }
72
- deviceCount = deviceCount + slice.length
70
+ if (data.length) {
71
+ allData.devices.push(...await processDevices(from, to, devices, userData.drivers, userData.geofences, data, traccar))
72
+ }
73
+ deviceCount = deviceCount + slice.length
74
+ }))
73
75
  }
76
+ await Promise.all(promises)
74
77
 
75
78
  reportData.push(allData)
76
79