fleetmap-reports 1.0.445 → 1.0.446
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/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -56,14 +56,14 @@ async function getReportData (from, to, devices, types, traccar) {
|
|
|
56
56
|
const arrayOfArrays = automaticReports.sliceArray(devices)
|
|
57
57
|
const traccarTypes = new Set(types.map(t => t.startsWith('alarm') ? 'alarm' : t))
|
|
58
58
|
const traccarSubTypes = types.map(t => t.startsWith('alarm') ? t.replace('alarm_', '') : '').filter(Boolean)
|
|
59
|
-
|
|
59
|
+
await Promise.all(arrayOfArrays.map(async a => {
|
|
60
60
|
const response = await traccar.reports.reportsEventsGet(from, to, a.map(d => d.id), null, traccarTypes)
|
|
61
61
|
if (types.length > 0) {
|
|
62
62
|
data = data.concat(response.data.filter(e => e.type === 'alarm' ? traccarSubTypes.includes(e.attributes.alarm) : true))
|
|
63
63
|
} else {
|
|
64
64
|
data = data.concat(response.data)
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}))
|
|
67
67
|
console.log('Alerts:' + data.length)
|
|
68
68
|
return data
|
|
69
69
|
}
|
|
@@ -72,8 +72,6 @@ async function processDevices (from, to, devices, geofences, drivers, data, trac
|
|
|
72
72
|
const devicesResult = []
|
|
73
73
|
let i = 0
|
|
74
74
|
await Promise.all(devices.map(async d => {
|
|
75
|
-
console.log('LOADING_MESSAGE:' + d.name)
|
|
76
|
-
console.log(`PROGRESS_PERC:${++i / devices.length * 100}`)
|
|
77
75
|
const alerts = data.filter(t => t.deviceId === d.id)
|
|
78
76
|
|
|
79
77
|
if (alerts.length > 0) {
|
|
@@ -100,6 +98,9 @@ async function processDevices (from, to, devices, geofences, drivers, data, trac
|
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
100
|
|
|
101
|
+
console.log('LOADING_MESSAGE:' + d.name)
|
|
102
|
+
console.log(`PROGRESS_PERC:${++i / devices.length * 100}`)
|
|
103
|
+
|
|
103
104
|
devicesResult.push({
|
|
104
105
|
device: d,
|
|
105
106
|
from,
|