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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.442",
3
+ "version": "1.0.445",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -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
- for (const d of devices) {
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, 339170.3099999875) // Total Kms
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, 13) // Total Trips
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)
@@ -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) {