fleetmap-reports 2.0.270 → 2.0.271
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.
|
|
3
|
+
"version": "2.0.271",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"jspdf": "^2.5.1",
|
|
24
24
|
"jspdf-autotable": "3.8.1",
|
|
25
25
|
"moment": "2.30.1",
|
|
26
|
-
"p-limit": "^6.2.0",
|
|
27
26
|
"piscina": "^4.9.2",
|
|
28
27
|
"stream-chain": "^3.4.0",
|
|
29
28
|
"stream-json": "^1.9.1",
|
package/src/location-report.js
CHANGED
|
@@ -47,16 +47,17 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
|
|
|
47
47
|
const devices = await traccar.axios.get(url).then(d => d.data)
|
|
48
48
|
console.log(devices.length)
|
|
49
49
|
|
|
50
|
-
if (!devices.length) {
|
|
51
|
-
// Empty report
|
|
52
|
-
return { drivers: [] }
|
|
53
|
-
}
|
|
50
|
+
if (!devices.length) { return { drivers: [] } }
|
|
54
51
|
|
|
55
|
-
const sliced = automaticReports.sliceArray(devices, 1)
|
|
56
52
|
const deviceCount = 0
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
53
|
+
const results = []
|
|
54
|
+
const batchSize = 10
|
|
55
|
+
for (let i = 0; i < devices.length; i += batchSize) {
|
|
56
|
+
const batch = devices.slice(i, i + batchSize)
|
|
57
|
+
const batchResults = await Promise.all(batch.map(device => _getDriverRoute(traccar, from, to, [device], deviceCount, devices, userData)))
|
|
58
|
+
results.push(...batchResults)
|
|
59
|
+
}
|
|
60
|
+
return { drivers: results.flat() }
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData) {
|
|
@@ -37,7 +37,7 @@ describe('test positions', function () {
|
|
|
37
37
|
console.log(driver.positions)
|
|
38
38
|
assert.equal(driver.positions.length, 85) // Total Positions
|
|
39
39
|
} catch (e) {
|
|
40
|
-
console.error(e)
|
|
40
|
+
console.error(e.message, e.response && e.response.data, e)
|
|
41
41
|
}
|
|
42
42
|
}, 2000000)
|
|
43
43
|
// eslint-disable-next-line no-undef
|