fleetmap-reports 1.0.775 → 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
|
@@ -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,
|
|
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,
|
|
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,19 +125,20 @@ 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 =
|
|
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
|
|
136
137
|
const hardAcceleration = deviceRoute.filter(p => p.attributes.io253 === 1).length
|
|
137
138
|
|
|
138
139
|
return {
|
|
139
|
-
drivingTime,
|
|
140
|
-
idleTime,
|
|
140
|
+
drivingTime: drivingTime / 1000,
|
|
141
|
+
idleTime: idleTime / 1000,
|
|
141
142
|
cruiseControlTime: 0,
|
|
142
143
|
economicTime: 0,
|
|
143
144
|
highEngineRPM: 0,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const { getReports } = require('./index')
|
|
2
2
|
const { createPerformanceReport } = require('../partnerReports/performance-report')
|
|
3
3
|
const assert = require('assert')
|
|
4
|
+
const { convertMS } = require('../util/utils')
|
|
4
5
|
// eslint-disable-next-line no-undef
|
|
5
6
|
describe('performance', function () {
|
|
6
7
|
// eslint-disable-next-line no-undef
|
|
7
|
-
it('performance report', async () => {
|
|
8
|
+
it('performance report teltonika', async () => {
|
|
8
9
|
const report = await getReports()
|
|
9
10
|
const userData = await report.getUserData()
|
|
10
11
|
userData.devices = userData.devices.filter(d => d.id === 22326)
|
|
@@ -13,11 +14,13 @@ describe('performance', function () {
|
|
|
13
14
|
new Date(Date.UTC(2023, 5, 20, 23, 59, 59, 0)),
|
|
14
15
|
userData,
|
|
15
16
|
report.traccar)
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
assert.equal(data[0].consumption, 21.8)
|
|
18
|
+
assert.equal(data[0].distance, 381.29861000000005)
|
|
19
|
+
assert.equal(convertMS(data[1].time * 1000, false), '10:30')
|
|
20
|
+
}, 8000000)
|
|
18
21
|
|
|
19
22
|
// eslint-disable-next-line no-undef
|
|
20
|
-
it('performance report
|
|
23
|
+
it('performance report inofleet', async () => {
|
|
21
24
|
const report = await getReports()
|
|
22
25
|
const userData = await report.getUserData()
|
|
23
26
|
userData.devices = userData.devices.filter(d => d.id === 69114)
|