fleetmap-reports 1.0.776 → 1.0.777

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.776",
3
+ "version": "1.0.777",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -12,7 +12,7 @@ async function createPerformanceReport (from, to, userData, traccar) {
12
12
  const sliced = automaticReports.sliceArray(devices, 5)
13
13
  let deviceCount = 0
14
14
  for (const slice of sliced) {
15
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, false, false, deviceCount, devices.length)
15
+ const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, true, true, deviceCount, devices.length)
16
16
 
17
17
  slice.forEach(d => {
18
18
  const deviceData = getDeviceData(allInOne, d)
@@ -23,7 +23,7 @@ async function createPerformanceReport (from, to, userData, traccar) {
23
23
  deviceCount = deviceCount + slice.length
24
24
  }
25
25
  } else {
26
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, userData.devices, true, true, false, true)
26
+ const allInOne = await traccarHelper.getAllInOne(traccar, from, to, userData.devices, true, true, true, true)
27
27
 
28
28
  const device = userData.devices[0]
29
29
 
@@ -125,11 +125,12 @@ function getDeviceData (allInOne, d) {
125
125
  }
126
126
  } else {
127
127
  const deviceSummary = allInOne.summary.filter(t => t.deviceId === d.id)[0]
128
+ const deviceStops = allInOne.stops.filter(t => t.deviceId === d.id)
128
129
 
129
130
  const drivingTime = deviceTrips.reduce((a, b) => a + b.duration, 0)
130
131
  const drivingConsumption = deviceTrips.reduce((a, b) => a + b.spentFuel, 0)
131
132
  const drivingDistance = deviceSummary ? deviceSummary.distance / 1000 : 0
132
- const idleTime = deviceSummary && deviceSummary.engineHours > drivingTime ? deviceSummary.engineHours - drivingTime : 0
133
+ const idleTime = deviceTrips.reduce((a, b) => a + b.idleTime, 0) + deviceStops.reduce((a, b) => a + b.engineHours, 0)
133
134
  const idleConsumption = deviceSummary && deviceSummary.spentFuel > drivingConsumption ? deviceSummary.spentFuel - drivingConsumption : 0
134
135
 
135
136
  const hardBreaking = deviceRoute.filter(p => p.attributes.io253 === 2).length