fleetmap-reports 1.0.722 → 1.0.723
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 +22 -0
- package/src/zone-report.js +2 -1
package/package.json
CHANGED
package/src/tests/zones.test.js
CHANGED
|
@@ -47,4 +47,26 @@ describe('zones', function () {
|
|
|
47
47
|
assert.equal(first.inTime.fixTime, '2023-01-03T21:23:24.000+0000')
|
|
48
48
|
assert.equal(first.outTime.fixTime, '2023-01-07T12:22:53.000+0000')
|
|
49
49
|
}, 4000000)
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line no-undef
|
|
52
|
+
it('works with casais 2', async () => {
|
|
53
|
+
const report = await getReports('mario.andre.moreira@casais.gi', 'Casais.23')
|
|
54
|
+
const userData = await report.getUserData()
|
|
55
|
+
userData.groupByDay = true
|
|
56
|
+
userData.devices = userData.devices.filter(d => d.name === 'G-2542-F Fiat Tipo')
|
|
57
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ')
|
|
58
|
+
assert.equal(userData.geofences.length > 0, true)
|
|
59
|
+
assert.equal(userData.devices.length > 0, true)
|
|
60
|
+
const result = await report.zoneReport(
|
|
61
|
+
new Date(Date.UTC(2023, 1, 27, 0, 0, 0, 0)),
|
|
62
|
+
new Date(Date.UTC(2023, 1, 27, 23, 59, 59, 0)),
|
|
63
|
+
userData)
|
|
64
|
+
assert.equal(result[0].devices[0].geofences.length, 1)
|
|
65
|
+
assert.equal(result[0].devices[0].geofences[0].days.length, 1)
|
|
66
|
+
const first = result[0].devices[0].geofences[0].days[0]
|
|
67
|
+
console.log(first)
|
|
68
|
+
assert.equal(first.firstIn, '2023-02-27T21:53:16.000+0000')
|
|
69
|
+
assert.equal(first.distanceIn, 93.03917199839687)
|
|
70
|
+
assert.equal(first.distanceOut, 819.6685737216337)
|
|
71
|
+
}, 4000000)
|
|
50
72
|
})
|
package/src/zone-report.js
CHANGED
|
@@ -119,7 +119,8 @@ async function processDevices (from, to, devices, userData, data) {
|
|
|
119
119
|
let distanceIn = zoneInOutDayData.length && dayRoute.length ? zoneInOutDayData.reduce((a, b) => a + (b.distanceIn || 0), 0) : 0
|
|
120
120
|
let distanceOut = 0
|
|
121
121
|
if (zoneInOutDayData.length) {
|
|
122
|
-
distanceOut = zoneInOutDayData.reduce((a, b) => a + (b.distanceOut || 0), 0) -
|
|
122
|
+
distanceOut = zoneInOutDayData.reduce((a, b) => a + (b.distanceOut || 0), 0) -
|
|
123
|
+
(zoneInOutDayData[zoneInOutDayData.length - 1].distanceOut || 0)
|
|
123
124
|
} else {
|
|
124
125
|
distanceOut = calculateDistance(deviceRoute.filter(p => new Date(p.fixTime) >= fromByDay && new Date(p.fixTime) < toByDay))
|
|
125
126
|
}
|