fleetmap-reports 1.0.363 → 1.0.366
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 -1
- package/src/speeding-report.js +1 -1
- package/src/util/trips.js +7 -2
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -205,7 +205,7 @@ function processDevices(from, to, devices, data, userData) {
|
|
|
205
205
|
s.distance = deviceTrips.reduce((a, b) => a + b.distance, 0)
|
|
206
206
|
s.convertedSpentFuel = automaticReports.calculateSpentFuel(s.spentFuel, d)
|
|
207
207
|
s.startTime = deviceTrips.length && deviceTrips[0].startTime
|
|
208
|
-
s.endTime =
|
|
208
|
+
s.endTime = deviceTrips.length && deviceTrips[deviceTrips.length-1].endTime
|
|
209
209
|
})
|
|
210
210
|
}
|
|
211
211
|
}
|
package/src/speeding-report.js
CHANGED
|
@@ -95,7 +95,7 @@ async function createSpeedingReportByDevice(from, to, userData, traccarInstance)
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
async function createSpeedingReportByDriver(from, to, userData) {
|
|
98
|
+
async function createSpeedingReportByDriver(from, to, userData, traccarInstance) {
|
|
99
99
|
const devices = await drivers.devicesByDriver(traccarInstance, from, to, userData.drivers, userData.devices)
|
|
100
100
|
console.log('Devices with driver',devices.length)
|
|
101
101
|
|
package/src/util/trips.js
CHANGED
|
@@ -163,8 +163,8 @@ function calculateTrip(device, route) {
|
|
|
163
163
|
deviceId: device.id,
|
|
164
164
|
deviceName: device.name,
|
|
165
165
|
distance: route.reduce((a, b) => a + b.attributes.distance, 0),
|
|
166
|
-
averageSpeed: Math.round((route.reduce((a, b) => a
|
|
167
|
-
maxSpeed: route.reduce(function (
|
|
166
|
+
averageSpeed: Math.round((route.map(p => p.speed).reduce((a, b) => a + b, 0)) / route.length),
|
|
167
|
+
maxSpeed: route.map(p => p.speed).reduce(function (a, b) { return Math.max(a, b) }),
|
|
168
168
|
spentFuel: 0,
|
|
169
169
|
startOdometer: startPos.attributes.odometer || startPos.attributes.totalDistance,
|
|
170
170
|
endOdometer: endPos.attributes.odometer || endPos.attributes.totalDistance,
|
|
@@ -174,6 +174,11 @@ function calculateTrip(device, route) {
|
|
|
174
174
|
startLon: startPos.longitude,
|
|
175
175
|
startTime: startPos.fixTime,
|
|
176
176
|
startAddress: startPos.address,
|
|
177
|
+
endLat: endPos.latitude,
|
|
178
|
+
endLon: endPos.longitude,
|
|
179
|
+
endTime: endPos.fixTime,
|
|
180
|
+
endAddress: endPos.address,
|
|
181
|
+
endTimeIsOut: true,
|
|
177
182
|
duration: new Date(endPos.fixTime).getTime() - new Date(startPos.fixTime).getTime(),
|
|
178
183
|
driverUniqueId: null,
|
|
179
184
|
driverName: null
|