fleetmap-reports 1.0.825 → 1.0.826
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/events-report.js +5 -4
- package/src/tests/events.test.js +1 -0
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -61,9 +61,10 @@ async function getReportData (from, to, devices, types, traccar) {
|
|
|
61
61
|
const traccarTypes = new Set(types.map(t => t.startsWith('alarm') ? 'alarm' : t))
|
|
62
62
|
await Promise.all(arrayOfArrays.map(async a => {
|
|
63
63
|
const response = await traccar.reports.reportsEventsGet(from, to, a.map(d => d.id), null, traccarTypes)
|
|
64
|
-
|
|
65
|
-
data
|
|
66
|
-
|
|
64
|
+
data = data.concat(
|
|
65
|
+
response.data.filter(
|
|
66
|
+
e => types.find(t => t === e.type) || types.find(t => t.replace('alarm_', '') === e.attributes.alarm)
|
|
67
|
+
))
|
|
67
68
|
}))
|
|
68
69
|
console.log('Alerts:' + data.length)
|
|
69
70
|
return data
|
|
@@ -83,7 +84,7 @@ async function processDevices (from, to, devices, data, traccar, userData) {
|
|
|
83
84
|
for (const a of deviceAlerts) {
|
|
84
85
|
a.position = positions.find(p => p.id === a.positionId)
|
|
85
86
|
|
|
86
|
-
if (!a.geofenceId) {
|
|
87
|
+
if (!a.geofenceId && a.position) {
|
|
87
88
|
const poi = getNearestPOI(a.position, userData.geofences)
|
|
88
89
|
a.geofenceId = poi && poi.p.id
|
|
89
90
|
}
|
package/src/tests/events.test.js
CHANGED
|
@@ -13,6 +13,7 @@ describe('events', function () {
|
|
|
13
13
|
console.log('result', result)
|
|
14
14
|
}, 4000000)
|
|
15
15
|
|
|
16
|
+
// eslint-disable-next-line no-undef
|
|
16
17
|
it('works with pois', async () => {
|
|
17
18
|
const report = await getReports(process.env.USER_NOGARTEL, process.env.PASS_NOGARTEL)
|
|
18
19
|
const userData = await report.getUserData()
|