fleetmap-reports 1.0.762 → 1.0.764
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/performance.test.js +3 -4
- package/src/tests/zones.test.js +3 -40
- package/src/zone-report.js +12 -9
package/package.json
CHANGED
|
@@ -2,15 +2,14 @@ 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)
|
|
6
5
|
// eslint-disable-next-line no-undef
|
|
7
6
|
it('performance report', async () => {
|
|
8
7
|
const report = await getReports()
|
|
9
8
|
const userData = await report.getUserData()
|
|
10
|
-
userData.devices = userData.devices.filter(d => d.
|
|
9
|
+
userData.devices = userData.devices.filter(d => d.attributes.xpert)
|
|
11
10
|
const data = await createPerformanceReport(
|
|
12
|
-
new Date(Date.UTC(2023, 5,
|
|
13
|
-
new Date(Date.UTC(2023, 5,
|
|
11
|
+
new Date(Date.UTC(2023, 5, 10, 0, 0, 0, 0)),
|
|
12
|
+
new Date(Date.UTC(2023, 5, 20, 23, 59, 59, 0)),
|
|
14
13
|
userData,
|
|
15
14
|
report.traccar)
|
|
16
15
|
console.log(data)
|
package/src/tests/zones.test.js
CHANGED
|
@@ -2,7 +2,6 @@ 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)
|
|
6
5
|
// eslint-disable-next-line no-undef
|
|
7
6
|
it('works with ellca', async () => {
|
|
8
7
|
const report = await getReports()
|
|
@@ -55,50 +54,14 @@ describe('zones', function () {
|
|
|
55
54
|
const userData = await report.getUserData()
|
|
56
55
|
userData.zonesByColumn = true
|
|
57
56
|
userData.devices = userData.devices.filter(d => d.name === 'G-1101-E Clio')
|
|
58
|
-
userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ')
|
|
57
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ')
|
|
58
|
+
userData.onlyWithKmsOut = true
|
|
59
59
|
const result = await report.zoneReport(
|
|
60
60
|
new Date(Date.UTC(2023, 0, 1, 0, 0, 0, 0)),
|
|
61
61
|
new Date(Date.UTC(2023, 0, 31, 23, 59, 59, 0)),
|
|
62
62
|
userData)
|
|
63
63
|
const first = result[0].devices[0].days[0]
|
|
64
64
|
console.log(first)
|
|
65
|
-
assert.equal(first.distanceOut,
|
|
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')
|
|
65
|
+
assert.equal(first.distanceOut, 35.52274536571346)
|
|
103
66
|
}, 4000000)
|
|
104
67
|
})
|
package/src/zone-report.js
CHANGED
|
@@ -131,7 +131,7 @@ async function processDevices (from, to, devices, userData, data) {
|
|
|
131
131
|
geofencesData.push({
|
|
132
132
|
geofenceId: geofence.id,
|
|
133
133
|
geofenceName: geofence.name,
|
|
134
|
-
days: dataByDay
|
|
134
|
+
days: userData.onlyWithKmsOut ? dataByDay.filter(d => d.distanceOut) : dataByDay
|
|
135
135
|
})
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -147,19 +147,22 @@ async function processDevices (from, to, devices, userData, data) {
|
|
|
147
147
|
const distanceOut = calculateDistanceOut(zoneInOutDayData, deviceRoute, fromByDay, toByDay, 'distanceOutAny')
|
|
148
148
|
|
|
149
149
|
const geofences = geofencesData.map(g => {
|
|
150
|
+
const day = g.days.find(day => day.date === date)
|
|
150
151
|
return {
|
|
151
152
|
geofenceId: g.geofenceId,
|
|
152
153
|
geofenceName: g.geofenceName,
|
|
153
|
-
distanceIn:
|
|
154
|
+
distanceIn: day && day.distanceIn
|
|
154
155
|
}
|
|
155
156
|
})
|
|
156
157
|
|
|
157
|
-
if (distanceOut || geofences.filter(g => g.distanceIn).length) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
if (distanceOut > 0.01 || geofences.filter(g => g.distanceIn > 0.01).length) {
|
|
159
|
+
if (!userData.onlyWithKmsOut || distanceOut) {
|
|
160
|
+
groupByDay.push({
|
|
161
|
+
date,
|
|
162
|
+
geofences,
|
|
163
|
+
distanceOut
|
|
164
|
+
})
|
|
165
|
+
}
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
168
|
|
|
@@ -187,7 +190,7 @@ async function processDevices (from, to, devices, userData, data) {
|
|
|
187
190
|
device: d,
|
|
188
191
|
from,
|
|
189
192
|
to,
|
|
190
|
-
geofences: zoneInOutData
|
|
193
|
+
geofences: userData.onlyWithKmsOut ? zoneInOutData.filter(a => a.distanceOut) : zoneInOutData
|
|
191
194
|
})
|
|
192
195
|
}
|
|
193
196
|
}
|