fleetmap-reports 1.0.442 → 1.0.445
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/events-report.js +3 -3
- package/src/index.test.js +2 -2
- package/src/trip-report.js +1 -1
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -71,7 +71,7 @@ async function getReportData (from, to, devices, types, traccar) {
|
|
|
71
71
|
async function processDevices (from, to, devices, geofences, drivers, data, traccar) {
|
|
72
72
|
const devicesResult = []
|
|
73
73
|
let i = 0
|
|
74
|
-
|
|
74
|
+
await Promise.all(devices.map(async d => {
|
|
75
75
|
console.log('LOADING_MESSAGE:' + d.name)
|
|
76
76
|
console.log(`PROGRESS_PERC:${++i / devices.length * 100}`)
|
|
77
77
|
const alerts = data.filter(t => t.deviceId === d.id)
|
|
@@ -107,7 +107,7 @@ async function processDevices (from, to, devices, geofences, drivers, data, trac
|
|
|
107
107
|
alerts
|
|
108
108
|
})
|
|
109
109
|
}
|
|
110
|
-
}
|
|
110
|
+
}))
|
|
111
111
|
|
|
112
112
|
return devicesResult
|
|
113
113
|
}
|
|
@@ -261,7 +261,7 @@ function getAlertInfo (drivers, alert) {
|
|
|
261
261
|
const driver = drivers.find(d => d.uniqueId === alert.attributes.driverUniqueId)
|
|
262
262
|
return driver ? driver.name : alert.attributes.driverUniqueId
|
|
263
263
|
}
|
|
264
|
-
return
|
|
264
|
+
return alert.driver
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
function getAlertDate (user, alert) {
|
package/src/index.test.js
CHANGED
|
@@ -50,7 +50,7 @@ describe('Test_Reports', function () {
|
|
|
50
50
|
assert.equal(device.trips.length, 7) // Total Trips
|
|
51
51
|
assert.equal(device.trips[0].endPOIName, 'Casa João')
|
|
52
52
|
assert.equal(device.trips[1].endPOIName, undefined)
|
|
53
|
-
assert.equal(device.totalDistance,
|
|
53
|
+
assert.equal(device.totalDistance, 339204.53999999166) // Total Kms
|
|
54
54
|
}, 20000)
|
|
55
55
|
// eslint-disable-next-line no-undef
|
|
56
56
|
it('Trip by driver', async () => {
|
|
@@ -63,7 +63,7 @@ describe('Test_Reports', function () {
|
|
|
63
63
|
assert.equal(data.length, 1)
|
|
64
64
|
console.log(data[0].drivers)
|
|
65
65
|
const driver = data[0].drivers.find(d => d.driver.id === 14020)
|
|
66
|
-
assert.equal(driver.trips.length,
|
|
66
|
+
assert.equal(driver.trips.length, 9) // Total Trips
|
|
67
67
|
assert.equal(driver.totalDuration, 6274000)
|
|
68
68
|
assert.equal(driver.maxSpeed, 70.1944)
|
|
69
69
|
}, 20000)
|
package/src/trip-report.js
CHANGED
|
@@ -276,7 +276,7 @@ async function exportTripReportToPDF (userData, reportData) {
|
|
|
276
276
|
tripsData.forEach(function (d, index) {
|
|
277
277
|
const data = []
|
|
278
278
|
const name = userData.byDriver ? d.driver.name : deviceName(d.device)
|
|
279
|
-
const group = userData.byDriver ? userData.groups.find(g => g.drivers.includes(d.id)) : userData.groups.find(g => d.device.groupId === g.id)
|
|
279
|
+
const group = userData.byDriver ? userData.groups.find(g => g.drivers && g.drivers.includes(d.id)) : userData.groups.find(g => d.device.groupId === g.id)
|
|
280
280
|
|
|
281
281
|
const space = index === 0 ? 8 : 0
|
|
282
282
|
if (index) {
|