fleetmap-reports 1.0.774 → 1.0.775

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.774",
3
+ "version": "1.0.775",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -124,13 +124,13 @@ function getDeviceData (allInOne, d) {
124
124
  economicDistance
125
125
  }
126
126
  } else {
127
- const deviceSummary = allInOne.summary.filter(t => t.deviceId === d.id)
127
+ const deviceSummary = allInOne.summary.filter(t => t.deviceId === d.id)[0]
128
128
 
129
129
  const drivingTime = deviceTrips.reduce((a, b) => a + b.duration, 0)
130
130
  const drivingConsumption = deviceTrips.reduce((a, b) => a + b.spentFuel, 0)
131
- const drivingDistance = deviceSummary[0].distance / 1000
132
- const idleTime = deviceSummary[0].engineHours > drivingTime ? deviceSummary[0].engineHours - drivingTime : 0
133
- const idleConsumption = deviceSummary[0].spentFuel > drivingConsumption ? deviceSummary[0].spentFuel - drivingConsumption : 0
131
+ const drivingDistance = deviceSummary ? deviceSummary.distance / 1000 : 0
132
+ const idleTime = deviceSummary && deviceSummary.engineHours > drivingTime ? deviceSummary.engineHours - drivingTime : 0
133
+ const idleConsumption = deviceSummary && deviceSummary.spentFuel > drivingConsumption ? deviceSummary.spentFuel - drivingConsumption : 0
134
134
 
135
135
  const hardBreaking = deviceRoute.filter(p => p.attributes.io253 === 2).length
136
136
  const hardAcceleration = deviceRoute.filter(p => p.attributes.io253 === 1).length