fleetmap-reports 1.0.635 → 1.0.637

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.635",
3
+ "version": "1.0.637",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -209,7 +209,7 @@ function findGeofenceData (event, userData) {
209
209
  if (geofence) {
210
210
  const group = userData.groups.find(g => g.geofenceIds && g.geofenceIds.includes(geofence.id))
211
211
  event.geofenceName = geofence.name
212
- event.geofenceGroup = group.name || ''
212
+ event.geofenceGroup = (group && group.name) || ''
213
213
  }
214
214
  }
215
215
 
@@ -38,13 +38,23 @@ async function createActivityReport (from, to, userData, traccarInstance) {
38
38
 
39
39
  const totalDistance = trips.reduce((a, b) => a + b.distance, 0)
40
40
  const drivingTime = trips.reduce((a, b) => a + b.duration, 0)
41
- const stopTime = stops.reduce((a, b) => a + (b.duration > b.engineHours ? (b.duration - b.engineHours) : 0), 0)
41
+ let stopTime = stops.reduce((a, b) => a + (b.duration > b.engineHours ? (b.duration - b.engineHours) : 0), 0)
42
42
 
43
43
  const idleTimeArray = idleEvents.map(e => e.idleTime).filter(a => a > 0)
44
44
 
45
45
  const startTrip = trips.length ? trips[0] : undefined
46
46
  const endTrip = trips.length ? trips[trips.length - 1] : undefined
47
47
 
48
+ /* if (stops.length > 0 && startTrip) {
49
+ if (startTrip.startTime > stops[0].startTime) {
50
+
51
+ }
52
+ }
53
+ stopTime = stopTime + (new Date(startTrip).getTime() - from.getTime())
54
+ */
55
+
56
+ stopTime = endTrip ? stopTime + (to.getTime() - new Date(endTrip.endTime).getTime()) : stopTime
57
+
48
58
  const startNearestPOIs = startTrip ? getNearestPOIs(startTrip.startLon, startTrip.startLat, userData.geofences) : []
49
59
  const endNearestPOIs = endTrip ? getNearestPOIs(endTrip.endLon, endTrip.endLat, userData.geofences) : []
50
60