fleetmap-reports 1.0.691 → 1.0.693

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 +16 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.691",
3
+ "version": "1.0.693",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -20,11 +20,23 @@ const deviceChunk = 5
20
20
  const fileName = 'ZoneReport'
21
21
 
22
22
  async function createZoneReport (from, to, userData, traccar) {
23
+ const reportData = []
24
+ const devices = devicesToProcess(userData)
25
+ const allData = {
26
+ devices: [],
27
+ xpert: devices.filter(d => d.attributes.xpert).length > 0
28
+ }
29
+
23
30
  if (processServerSide(userData)) {
24
31
  const url = `https://${process.env.SERVER_HOST}/reports/zone-report`
25
- return axios.post(url, { from, to, userData }, { withCredentials: true }).then(d => d.data)
32
+ const sliced = automaticReports.sliceArray(devices, sliceSize)
33
+ for (const slice of sliced) {
34
+ const data = await axios.post(url, { from, to, userData: { ...userData, devices: slice } }, { withCredentials: true }).then(d => d.data)
35
+ allData.devices.push(...(data[0].devices))
36
+ }
37
+ reportData.push(allData)
38
+ return reportData
26
39
  }
27
- const reportData = []
28
40
  const types = ['geofenceEnter', 'geofenceExit']
29
41
 
30
42
  if (userData.byGroup) {
@@ -50,13 +62,6 @@ async function createZoneReport (from, to, userData, traccar) {
50
62
  }
51
63
  }
52
64
 
53
- const devices = devicesToProcess(userData)
54
-
55
- const allData = {
56
- devices: [],
57
- xpert: devices.filter(d => d.attributes.xpert).length > 0
58
- }
59
-
60
65
  const sliced = automaticReports.sliceArray(devices, sliceSize)
61
66
 
62
67
  let deviceCount = 0
@@ -301,10 +306,11 @@ function checkGeofenceExit (p1, p2, g) {
301
306
 
302
307
  function getInAndOutEvents (devices, route, userData) {
303
308
  const events = []
309
+ const geofencesFeatures = userData.geofences.map(g => convertToFeature(g))
310
+
304
311
  devices.forEach(d => {
305
312
  const deviceRoute = route.filter(p => p.deviceId === d.id)
306
313
  const routePoints = deviceRoute.sort(sortPositions).map(p => convertPositionToFeature(p))
307
- const geofencesFeatures = userData.geofences.map(g => convertToFeature(g))
308
314
  const deviceEvents = []
309
315
  routePoints.filter(p => p.properties.position.valid).forEach((p, i, array) => {
310
316
  if (!i) {