fleetmap-reports 2.0.278 → 2.0.279

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": "2.0.278",
3
+ "version": "2.0.279",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -57,7 +57,16 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
57
57
  const batchResults = await Promise.all(batch.map(device => _getDriverRoute(traccar, from, to, [device], deviceCount, devices, userData)))
58
58
  const filtered = batchResults.filter(r => r && r.length)
59
59
  console.log(i, '/', devices.length, 'pushing', filtered, batchResults)
60
- results.push(...filtered)
60
+ filtered.forEach(r => {
61
+ if (r.driver && r.positions) {
62
+ const driver = results.find(d => d.driver && d.driver.id === r.driver.id)
63
+ if (driver) {
64
+ driver.positions = driver.positions.concat(r.positions).sort((a, b) => new Date(a.fixTime).getTime() - new Date(b.fixTime).getTime())
65
+ } else {
66
+ results.push(r)
67
+ }
68
+ }
69
+ })
61
70
  }
62
71
  return { drivers: results.flat() }
63
72
  }
@@ -33,7 +33,8 @@ describe('test positions', function () {
33
33
  new Date(Date.UTC(2025, 0, 31, 23, 59, 59, 0)),
34
34
  userData)
35
35
  assert.equal(data.length, 1)
36
- const driver = data[0].drivers.find(d => d.name.startsWith('ERICA'))
36
+ console.log(data[0].drivers)
37
+ const driver = data[0].drivers.find(d => d.name && d.name.startsWith('ERICA'))
37
38
  console.log(driver.positions)
38
39
  assert.equal(driver.positions.length, 85) // Total Positions
39
40
  } catch (e) {