fleetmap-reports 1.0.699 → 1.0.701
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 +1 -1
- package/src/tests/zones.test.js +14 -8
- package/src/util/utils.js +1 -1
- package/src/zone-report.js +13 -3
package/package.json
CHANGED
package/src/tests/zones.test.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const { getReports } = require('./index')
|
|
2
|
+
const assert = require('assert')
|
|
3
|
+
// eslint-disable-next-line no-undef
|
|
2
4
|
describe('zones', function () {
|
|
5
|
+
// eslint-disable-next-line no-undef
|
|
3
6
|
it('works with ellca', async () => {
|
|
4
7
|
const report = await getReports()
|
|
5
8
|
const userData = await report.getUserData()
|
|
@@ -16,16 +19,19 @@ describe('zones', function () {
|
|
|
16
19
|
console.log('result', result)
|
|
17
20
|
}, 4000000)
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
// eslint-disable-next-line no-undef
|
|
23
|
+
it('works with casais', async () => {
|
|
24
|
+
const report = await getReports('mario.andre.moreira@casais.gi', 'Casais.23')
|
|
21
25
|
const userData = await report.getUserData()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
console.log(userData.geofences)
|
|
26
|
+
userData.devices = userData.devices.filter(d => d.name === 'G-1101-E Clio')
|
|
27
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ')
|
|
25
28
|
const result = await report.zoneReport(
|
|
26
|
-
new Date(Date.UTC(2023,
|
|
27
|
-
new Date(Date.UTC(2023,
|
|
29
|
+
new Date(Date.UTC(2023, 0, 1, 0, 0, 0, 0)),
|
|
30
|
+
new Date(Date.UTC(2023, 0, 31, 23, 59, 59, 0)),
|
|
28
31
|
userData)
|
|
29
|
-
|
|
32
|
+
const first = result[0].devices[0].geofences[0]
|
|
33
|
+
console.log(first)
|
|
34
|
+
assert.equal(first.inTime.fixTime, '2023-01-03T21:23:24.000+0000')
|
|
35
|
+
assert.equal(first.outTime.fixTime, '2023-01-07T12:22:53.000+0000')
|
|
30
36
|
}, 4000000)
|
|
31
37
|
})
|
package/src/util/utils.js
CHANGED
package/src/zone-report.js
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
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
|
|
|
@@ -315,7 +325,7 @@ function getInAndOutEvents (devices, route, userData) {
|
|
|
315
325
|
if (!checkGeofenceIn(p, g)) {
|
|
316
326
|
deviceEvents.push(createEvent('geofenceExit', d.id, p, g))
|
|
317
327
|
} else {
|
|
318
|
-
|
|
328
|
+
p.inside[id] = true
|
|
319
329
|
}
|
|
320
330
|
} else {
|
|
321
331
|
if (checkGeofenceIn(p, g)) {
|