fleetmap-reports 1.0.463 → 1.0.464

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.463",
3
+ "version": "1.0.464",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -75,35 +75,34 @@ async function processDevices (from, to, devices, data, traccar, userData) {
75
75
  await Promise.all(devices.map(async d => {
76
76
  const deviceAlerts = data.filter(t => t.deviceId === d.id)
77
77
 
78
- if (deviceAlerts.length > 0) {
79
- const response = await traccar.reports.reportsRouteGet(from, to, [d.id])
80
- const positions = response.data
81
-
82
- for (const a of deviceAlerts) {
83
- a.position = positions.find(p => p.id === a.positionId)
84
-
85
- if (a.geofenceId) {
86
- const geofence = userData.geofences.find(g => g.id === a.geofenceId)
87
- if (geofence) {
88
- if (a.type === 'deviceOverspeed') {
89
- a.geofenceName = geofence.name + ' (' + Math.round(a.attributes.speedLimit * 1.85200) + ' Km/h)'
90
- } else {
91
- a.geofenceName = geofence.name
92
- }
78
+ const response = await traccar.reports.reportsRouteGet(from, to, [d.id])
79
+ const positions = response.data
80
+
81
+ for (const a of deviceAlerts) {
82
+ a.position = positions.find(p => p.id === a.positionId)
83
+
84
+ if (a.geofenceId) {
85
+ const geofence = userData.geofences.find(g => g.id === a.geofenceId)
86
+ if (geofence) {
87
+ if (a.type === 'deviceOverspeed') {
88
+ a.geofenceName = geofence.name + ' (' + Math.round(a.attributes.speedLimit * 1.85200) + ' Km/h)'
89
+ } else {
90
+ a.geofenceName = geofence.name
93
91
  }
94
92
  }
95
-
96
- if (a.position && a.position.attributes.driverUniqueId) {
97
- const driver = userData.drivers.find(d => d.uniqueId === a.position.attributes.driverUniqueId)
98
- a.driver = driver && driver.name
99
- }
100
93
  }
101
94
 
102
- const alerts = deviceAlerts.filter(a => userData.allWeek || !userData.weekDays || (!a.position || isInside(a.position.fixTime, a.position.fixTime, userData)))
95
+ if (a.position && a.position.attributes.driverUniqueId) {
96
+ const driver = userData.drivers.find(d => d.uniqueId === a.position.attributes.driverUniqueId)
97
+ a.driver = driver && driver.name
98
+ }
99
+ }
103
100
 
104
- console.log('LOADING_MESSAGE:' + d.name)
105
- console.log(`PROGRESS_PERC:${++i / devices.length * 100}`)
101
+ const alerts = deviceAlerts.filter(a => userData.allWeek || !userData.weekDays || (!a.position || isInside(a.position.fixTime, a.position.fixTime, userData)))
102
+ console.log('LOADING_MESSAGE:' + d.name)
103
+ console.log(`PROGRESS_PERC:${++i / devices.length * 100}`)
106
104
 
105
+ if (alerts.length > 0) {
107
106
  devicesResult.push({
108
107
  device: d,
109
108
  from,