fleetmap-reports 1.0.761 → 1.0.762
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
|
@@ -2,14 +2,15 @@ const { getReports } = require('./index')
|
|
|
2
2
|
const { createPerformanceReport } = require('../partnerReports/performance-report')
|
|
3
3
|
// eslint-disable-next-line no-undef
|
|
4
4
|
describe('performance', function () {
|
|
5
|
+
this.timeout(500000)
|
|
5
6
|
// eslint-disable-next-line no-undef
|
|
6
7
|
it('performance report', async () => {
|
|
7
8
|
const report = await getReports()
|
|
8
9
|
const userData = await report.getUserData()
|
|
9
|
-
userData.devices = userData.devices.filter(d => d.
|
|
10
|
+
userData.devices = userData.devices.filter(d => d.id === 128270)
|
|
10
11
|
const data = await createPerformanceReport(
|
|
11
|
-
new Date(Date.UTC(2023, 5,
|
|
12
|
-
new Date(Date.UTC(2023, 5,
|
|
12
|
+
new Date(Date.UTC(2023, 5, 29, 0, 0, 0, 0)),
|
|
13
|
+
new Date(Date.UTC(2023, 5, 30, 23, 59, 59, 0)),
|
|
13
14
|
userData,
|
|
14
15
|
report.traccar)
|
|
15
16
|
console.log(data)
|
package/src/tests/zones.test.js
CHANGED
|
@@ -2,6 +2,7 @@ const { getReports } = require('./index')
|
|
|
2
2
|
const assert = require('assert')
|
|
3
3
|
// eslint-disable-next-line no-undef
|
|
4
4
|
describe('zones', function () {
|
|
5
|
+
this.timeout(500000)
|
|
5
6
|
// eslint-disable-next-line no-undef
|
|
6
7
|
it('works with ellca', async () => {
|
|
7
8
|
const report = await getReports()
|
|
@@ -63,4 +64,41 @@ describe('zones', function () {
|
|
|
63
64
|
console.log(first)
|
|
64
65
|
assert.equal(first.distanceOut, 0.0009407267222226043)
|
|
65
66
|
}, 4000000)
|
|
67
|
+
|
|
68
|
+
// eslint-disable-next-line no-undef
|
|
69
|
+
it('works with casais 2', async () => {
|
|
70
|
+
const report = await getReports('mario.andre.moreira@casais.gi', 'Casais.23')
|
|
71
|
+
const userData = await report.getUserData()
|
|
72
|
+
userData.groupByDay = true
|
|
73
|
+
userData.devices = userData.devices.filter(d => d.name === 'G-2542-F Fiat Tipo')
|
|
74
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ')
|
|
75
|
+
assert.equal(userData.geofences.length > 0, true)
|
|
76
|
+
assert.equal(userData.devices.length > 0, true)
|
|
77
|
+
const result = await report.zoneReport(
|
|
78
|
+
new Date(2023, 1, 27, 0, 0, 0, 0),
|
|
79
|
+
new Date(2023, 1, 27, 23, 59, 59, 0),
|
|
80
|
+
userData)
|
|
81
|
+
assert.equal(result[0].devices[0].geofences.length, 1)
|
|
82
|
+
assert.equal(result[0].devices[0].geofences[0].days.length, 1)
|
|
83
|
+
const first = result[0].devices[0].geofences[0].days[0]
|
|
84
|
+
assert.equal(first.firstIn, '2023-02-27T21:53:16.000+0000')
|
|
85
|
+
assert.equal(first.distanceIn, 93.03917199839687)
|
|
86
|
+
assert.equal(first.distanceOut, 819.6685737216337)
|
|
87
|
+
}, 4000000)
|
|
88
|
+
|
|
89
|
+
it('works with casais 3', async () => {
|
|
90
|
+
const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
|
|
91
|
+
const userData = await report.getUserData()
|
|
92
|
+
userData.zonesByColumn = true
|
|
93
|
+
userData.devices = userData.devices.filter(d => d.name === 'G-1101-E Clio')
|
|
94
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ' || g.name === 'baliza raio amarelo ')
|
|
95
|
+
const result = await report.zoneReport(
|
|
96
|
+
new Date(Date.UTC(2023, 0, 29, 0, 0, 0, 0)),
|
|
97
|
+
new Date(Date.UTC(2023, 0, 31, 23, 59, 59, 0)),
|
|
98
|
+
userData)
|
|
99
|
+
const first = result[0].devices[0].geofences[0]
|
|
100
|
+
console.log(first)
|
|
101
|
+
assert.equal(first.name, 'baliza raio verde ')
|
|
102
|
+
assert.equal(first.distanceIn, '1069.343491503579')
|
|
103
|
+
}, 4000000)
|
|
66
104
|
})
|
package/src/zone-report.js
CHANGED
|
@@ -237,7 +237,7 @@ function calculateDistanceIn (zoneInOutDayData, deviceRoute, dayRoute, fromByDay
|
|
|
237
237
|
if (zoneInOutDayData.length) {
|
|
238
238
|
// Check if the first entry starts only on the day before
|
|
239
239
|
if (!zoneInOutDayData[0].inTime || new Date(zoneInOutDayData[0].inTime.fixTime) < fromByDay) {
|
|
240
|
-
const routeDayBefore = deviceRoute.filter(p => (!zoneInOutDayData[0].inTime || new Date(p.fixTime) >= new Date(zoneInOutDayData[0].inTime.fixTime)) &&
|
|
240
|
+
const routeDayBefore = deviceRoute.filter(p => (!zoneInOutDayData[0].inTime || (new Date(p.fixTime) >= new Date(zoneInOutDayData[0].inTime.fixTime))) &&
|
|
241
241
|
new Date(p.fixTime) < fromByDay)
|
|
242
242
|
distanceIn = distanceIn - calculateDistance(routeDayBefore)
|
|
243
243
|
}
|
|
@@ -245,7 +245,7 @@ function calculateDistanceIn (zoneInOutDayData, deviceRoute, dayRoute, fromByDay
|
|
|
245
245
|
// Check if the last entry ends only on the next day
|
|
246
246
|
if (!zoneInOutDayData[zoneInOutDayData.length - 1].outTime || new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) > toByDay) {
|
|
247
247
|
const outTime = zoneInOutDayData[zoneInOutDayData.length - 1].outTime ? new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) : to
|
|
248
|
-
const routeDayAfter = deviceRoute.filter(p => new Date(p.fixTime)
|
|
248
|
+
const routeDayAfter = deviceRoute.filter(p => new Date(p.fixTime) < outTime && new Date(p.fixTime) > toByDay)
|
|
249
249
|
distanceIn = distanceIn - calculateDistance(routeDayAfter)
|
|
250
250
|
}
|
|
251
251
|
}
|