fleetmap-reports 1.0.455 → 1.0.458
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 +1 -1
- package/src/activity-report.js +1 -0
- package/src/trip-report.js +3 -0
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -252,6 +252,7 @@ function processDrivers (from, to, drivers, data, userData) {
|
|
|
252
252
|
drivers.forEach(d => {
|
|
253
253
|
const route = data.route.filter(p => p.attributes.driverUniqueId === d.uniqueId)
|
|
254
254
|
const trips = data.trips.filter(t => t.driverUniqueId === d.uniqueId)
|
|
255
|
+
trips.sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime())
|
|
255
256
|
if (trips.length > 0) {
|
|
256
257
|
const driverData = {
|
|
257
258
|
driver: d,
|
package/src/trip-report.js
CHANGED
|
@@ -135,6 +135,9 @@ async function createTripReportByDriver (from, to, userData, traccar) {
|
|
|
135
135
|
d.totalDistance = d.trips.reduce((a, b) => a + b.distance, 0)
|
|
136
136
|
d.maxSpeed = d.trips.reduce((a, b) => { return a > b.maxSpeed ? a : b.maxSpeed }, 0)
|
|
137
137
|
d.trips = d.trips.sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime())
|
|
138
|
+
d.trips.forEach(function (trip, i) {
|
|
139
|
+
trip.stopDuration = i !== d.trips.length - 1 ? (new Date(d.trips[i + 1].startTime) - new Date(trip.endTime)) : 0
|
|
140
|
+
})
|
|
138
141
|
})
|
|
139
142
|
|
|
140
143
|
return report
|