fleetmap-reports 2.0.275 → 2.0.277
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/location-report.js +12 -15
- package/src/tests/positions.test.js +1 -1
package/package.json
CHANGED
package/src/location-report.js
CHANGED
|
@@ -55,16 +55,15 @@ 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() }
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData) {
|
|
65
|
+
async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData, retry = 3) {
|
|
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,14 @@ async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices,
|
|
|
73
72
|
devices,
|
|
74
73
|
userData
|
|
75
74
|
}, { timeout: 1000 * 60 * 5 })
|
|
76
|
-
.catch(() =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
.catch(e => console.error(e))
|
|
85
|
-
.then(d => (d && d.data) || undefined)
|
|
75
|
+
.catch((e) => {
|
|
76
|
+
if (--retry) {
|
|
77
|
+
return _getDriverRoute(traccar, from, to, slice, deviceCount, devices, userData, retry)
|
|
78
|
+
} else {
|
|
79
|
+
console.error('giving up', slice[0].id, 'after 3 retries', e.message)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
.then(r => r.data)
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
async function getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData) {
|
|
@@ -96,7 +93,7 @@ async function getDriverRoute (traccar, from, to, slice, deviceCount, devices, u
|
|
|
96
93
|
false,
|
|
97
94
|
true
|
|
98
95
|
)
|
|
99
|
-
|
|
96
|
+
return processDrivers(from, to, userData, allInOne)
|
|
100
97
|
}
|
|
101
98
|
|
|
102
99
|
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 =
|
|
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)),
|