fleetmap-reports 2.0.274 → 2.0.276

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.274",
3
+ "version": "2.0.276",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -51,12 +51,12 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
51
51
 
52
52
  const deviceCount = 0
53
53
  const results = []
54
- const batchSize = 5
54
+ const batchSize = 50
55
55
  for (let i = 0; i < devices.length; i += batchSize) {
56
56
  const batch = devices.slice(i, i + batchSize)
57
57
  const batchResults = await Promise.all(batch.map(device => _getDriverRoute(traccar, from, to, [device], deviceCount, devices, userData)))
58
- const filtered = batchResults.filter(r => r)
59
- console.log(i, '/', devices.length, 'pushing', filtered)
58
+ const filtered = batchResults.filter(r => r && r.length)
59
+ console.log(i, '/', devices.length, 'pushing', filtered, batchResults)
60
60
  results.push(...filtered)
61
61
  }
62
62
  return { drivers: results.flat() }
@@ -71,7 +71,19 @@ async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices,
71
71
  deviceCount,
72
72
  devices,
73
73
  userData
74
- }, { timeout: 1000 * 60 * 5 }).then(d => d.data)
74
+ }, { timeout: 1000 * 60 * 5 })
75
+ .catch((e) => {
76
+ console.error('moving on', e)
77
+ return traccar.axios.post(url, {
78
+ from,
79
+ to,
80
+ slice,
81
+ deviceCount,
82
+ devices,
83
+ userData
84
+ }).then(d => d.data)
85
+ })
86
+ .then(d => d && d.data)
75
87
  }
76
88
 
77
89
  async function getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData) {
@@ -85,7 +97,7 @@ async function getDriverRoute (traccar, from, to, slice, deviceCount, devices, u
85
97
  false,
86
98
  true
87
99
  )
88
- await processDrivers(from, to, userData, allInOne)
100
+ return processDrivers(from, to, userData, allInOne)
89
101
  }
90
102
 
91
103
  async function createLocationReportByGroup (from, to, userData, traccar) {
@@ -27,7 +27,7 @@ describe('test positions', function () {
27
27
  try {
28
28
  const userData = await report.getUserData()
29
29
  userData.byDriver = true
30
- userData.drivers = [userData.drivers.pop()]
30
+ userData.drivers = userData.drivers.filter(d => d.name.startsWith('ERICA'))
31
31
  const data = await report.locationReport(
32
32
  new Date(Date.UTC(2025, 0, 1, 0, 0, 0)),
33
33
  new Date(Date.UTC(2025, 0, 31, 23, 59, 59, 0)),