fleetmap-reports 1.0.736 → 1.0.737
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
|
@@ -26,8 +26,8 @@ async function createPerformanceReport (from, to, userData, traccar) {
|
|
|
26
26
|
const endTripData = getEndTripMessage(t, deviceRoute)
|
|
27
27
|
const canDriverStyle = getCanDriverStyleMessage(t, deviceRoute)
|
|
28
28
|
|
|
29
|
-
t.endTripData = endTripData && parseEndTripMessage(endTripData.xpertString)
|
|
30
|
-
t.canDriverStyle = canDriverStyle && parseCanDriverStyleMessage(canDriverStyle.xpertString)
|
|
29
|
+
t.endTripData = endTripData && parseEndTripMessage(endTripData.xpertString || endTripData)
|
|
30
|
+
t.canDriverStyle = canDriverStyle && parseCanDriverStyleMessage(canDriverStyle.xpertString || canDriverStyle)
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
const deviceData = {
|
|
@@ -43,7 +43,7 @@ async function createPerformanceReport (from, to, userData, traccar) {
|
|
|
43
43
|
economicTime: deviceTrips.reduce((a, b) => a + (b.canDriverStyle ? b.canDriverStyle.totalTimeInEcoRange : 0), 0),
|
|
44
44
|
economicConsumption: deviceTrips.reduce((a, b) => a + (b.canDriverStyle ? b.canDriverStyle.totalFuelConsumptionInEcoRange : 0), 0),
|
|
45
45
|
economicDistance: deviceTrips.reduce((a, b) => a + (b.canDriverStyle ? b.canDriverStyle.totalDistanceInEcoRange : 0), 0),
|
|
46
|
-
highEngineRPM: deviceTrips.reduce((a, b) => a + (b.canDriverStyle ? b.canDriverStyle.
|
|
46
|
+
highEngineRPM: deviceTrips.reduce((a, b) => a + (b.canDriverStyle ? b.canDriverStyle.totalTimeWithHighRpmAndTorque : 0), 0),
|
|
47
47
|
hardBreaking: deviceTrips.reduce((a, b) => a + (b.canDriverStyle ? b.canDriverStyle.totalNumberOfHarshBrakes : 0), 0),
|
|
48
48
|
hardAcceleration: deviceTrips.reduce((a, b) => a + (b.canDriverStyle ? b.canDriverStyle.totalNumberOfHarshAccelerations : 0), 0)
|
|
49
49
|
}
|
|
@@ -2,6 +2,7 @@ const { getReports } = require('./index')
|
|
|
2
2
|
const { createPerformanceReport } = require('../partnerReports/performance-report')
|
|
3
3
|
// eslint-disable-next-line no-undef
|
|
4
4
|
describe('performance', function () {
|
|
5
|
+
this.timeout(500000)
|
|
5
6
|
// eslint-disable-next-line no-undef
|
|
6
7
|
it('performance report', async () => {
|
|
7
8
|
const report = await getReports()
|
package/src/util/xpert.js
CHANGED
|
@@ -45,17 +45,17 @@ function parseCanDriverStyleMessage (xpertMessage) {
|
|
|
45
45
|
function getEndTripMessage (trip, route) {
|
|
46
46
|
const p = route.find(p => new Date(p.fixTime).getTime() > new Date(trip.endTime).getTime() &&
|
|
47
47
|
p.attributes.xpert &&
|
|
48
|
-
p.attributes.xpert.find(x => x.type === '3'))
|
|
48
|
+
(Array.isArray(p.attributes.xpert) ? p.attributes.xpert.find(x => x.type === '3') : p.attributes.xpert.split(';').find(m => m.startsWith('3'))))
|
|
49
49
|
|
|
50
|
-
return p && p.attributes.xpert.find(x => x.type === '3')
|
|
50
|
+
return p && (Array.isArray(p.attributes.xpert) ? p.attributes.xpert.find(x => x.type === '3') : p.attributes.xpert.split(';').find(m => m.startsWith('3')))
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function getCanDriverStyleMessage (trip, route) {
|
|
54
54
|
const p = route.find(p => new Date(p.fixTime).getTime() > new Date(trip.endTime).getTime() &&
|
|
55
55
|
p.attributes.xpert &&
|
|
56
|
-
p.attributes.xpert.find(x => x.type === '4'))
|
|
56
|
+
(Array.isArray(p.attributes.xpert) ? p.attributes.xpert.find(x => x.type === '4') : p.attributes.xpert.split(';').find(m => m.startsWith('4'))))
|
|
57
57
|
|
|
58
|
-
return p && p.attributes.xpert.find(x => x.type === '4')
|
|
58
|
+
return p && (Array.isArray(p.attributes.xpert) ? p.attributes.xpert.find(x => x.type === '4') : p.attributes.xpert.split(';').find(m => m.startsWith('4')))
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
exports.parseEndTripMessage = parseEndTripMessage
|