fleetmap-reports 1.0.810 → 1.0.814
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 +3 -5
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -58,12 +58,9 @@ async function getReportData (from, to, devices, types, traccar) {
|
|
|
58
58
|
let data = []
|
|
59
59
|
const arrayOfArrays = automaticReports.sliceArray(devices)
|
|
60
60
|
const traccarTypes = new Set(types.map(t => t.startsWith('alarm') ? 'alarm' : t))
|
|
61
|
-
const traccarSubTypes = types.map(t => t.startsWith('alarm') ? t.replace('alarm_', '') : '').filter(Boolean)
|
|
62
61
|
await Promise.all(arrayOfArrays.map(async a => {
|
|
63
62
|
const response = await traccar.reports.reportsEventsGet(from, to, a.map(d => d.id), null, traccarTypes)
|
|
64
63
|
if (types.length > 0) {
|
|
65
|
-
data = data.concat(response.data.filter(e => e.type === 'alarm' ? traccarSubTypes.includes(e.attributes.alarm) : true))
|
|
66
|
-
} else {
|
|
67
64
|
data = data.concat(response.data)
|
|
68
65
|
}
|
|
69
66
|
}))
|
|
@@ -77,8 +74,9 @@ async function processDevices (from, to, devices, data, traccar, userData) {
|
|
|
77
74
|
for (let j = 0; j < devices.length; j += maxParallelRequests) {
|
|
78
75
|
await Promise.all(devices.slice(j, j + maxParallelRequests).map(async d => {
|
|
79
76
|
const deviceAlerts = data.filter(t => t.deviceId === d.id)
|
|
80
|
-
|
|
81
|
-
const
|
|
77
|
+
// events can arrive at bd very late, so we search with a 24 hours delay
|
|
78
|
+
const dayBefore = new Date(new Date(from).setDate(from.getDate() - 1))
|
|
79
|
+
const response = await traccar.reports.reportsRouteGet(dayBefore, to, [d.id])
|
|
82
80
|
const positions = response.data
|
|
83
81
|
|
|
84
82
|
for (const a of deviceAlerts) {
|