fleetmap-reports 1.0.994 → 1.0.997

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/trip-report.js +19 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.994",
3
+ "version": "1.0.997",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -268,29 +268,31 @@ async function processDrivers (from, to, userData, data) {
268
268
  }
269
269
 
270
270
  for (const d of userData.drivers) {
271
- const { trips } = getDriverData(d, data)
271
+ const { trips } = await getDriverData(d, data, userData)
272
272
 
273
- trips.forEach(trip => {
274
- trip.totalKms = trip.distance / 1000
273
+ if (trips) {
274
+ trips.forEach(trip => {
275
+ trip.totalKms = trip.distance / 1000
275
276
 
276
- const nearestPOIs = getNearestPOIs(trip.endLon, trip.endLat, userData.geofences)
277
- if (nearestPOIs.length > 0) {
278
- trip.endPOIName = nearestPOIs[0].p.name
279
- }
277
+ const nearestPOIs = getNearestPOIs(trip.endLon, trip.endLat, userData.geofences)
278
+ if (nearestPOIs.length > 0) {
279
+ trip.endPOIName = nearestPOIs[0].p.name
280
+ }
280
281
 
281
- const stop = data.stops.find(s => s.deviceId === trip.deviceId && (new Date(s.startTime).getTime() === new Date(trip.endTime).getTime()))
282
+ const stop = data.stops.find(s => s.deviceId === trip.deviceId && (new Date(s.startTime).getTime() === new Date(trip.endTime).getTime()))
282
283
 
283
- trip.stopEngineHours = getTripIdleTime(trip, idleEvents) + (stop ? stop.engineHours : 0)
284
- })
284
+ trip.stopEngineHours = getTripIdleTime(trip, idleEvents) + (stop ? stop.engineHours : 0)
285
+ })
285
286
 
286
- if (trips.length > 0) {
287
- const driverData = {
288
- driver: d,
289
- from,
290
- to,
291
- trips
287
+ if (trips.length > 0) {
288
+ const driverData = {
289
+ driver: d,
290
+ from,
291
+ to,
292
+ trips
293
+ }
294
+ driversResult.push(driverData)
292
295
  }
293
- driversResult.push(driverData)
294
296
  }
295
297
  }
296
298