fleetmap-reports 2.0.275 → 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.275",
3
+ "version": "2.0.276",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -55,8 +55,8 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
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() }
@@ -64,7 +64,6 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
64
64
 
65
65
  async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData) {
66
66
  const url = `https://${process.env.SERVER_HOST}/pinmeapi/process-report/get-driver-route`
67
- console.log(url, slice.length, slice[0].id, userData.drivers)
68
67
  return traccar.axios.post(url, {
69
68
  from,
70
69
  to,
@@ -73,16 +72,18 @@ async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices,
73
72
  devices,
74
73
  userData
75
74
  }, { timeout: 1000 * 60 * 5 })
76
- .catch(() => traccar.axios.post(url, {
77
- from,
78
- to,
79
- slice,
80
- deviceCount,
81
- devices,
82
- userData
83
- }))
84
- .catch(e => console.error(e))
85
- .then(d => (d && d.data) || undefined)
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)
86
87
  }
87
88
 
88
89
  async function getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData) {
@@ -96,7 +97,7 @@ async function getDriverRoute (traccar, from, to, slice, deviceCount, devices, u
96
97
  false,
97
98
  true
98
99
  )
99
- await processDrivers(from, to, userData, allInOne)
100
+ return processDrivers(from, to, userData, allInOne)
100
101
  }
101
102
 
102
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)),