fleetmap-reports 1.0.370 → 1.0.371
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/automaticReports.js +1 -2
- package/src/util/traccar.js +11 -8
package/package.json
CHANGED
package/src/automaticReports.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const moment = require('moment')
|
|
2
2
|
|
|
3
|
-
function sliceArray(longArray) {
|
|
3
|
+
function sliceArray(longArray, size = 1) {
|
|
4
4
|
const arrayToSlice = longArray.slice()
|
|
5
5
|
|
|
6
|
-
const size = 1
|
|
7
6
|
const arrayOfArrays = []
|
|
8
7
|
for (let i=0; i<arrayToSlice.length; i+=size) {
|
|
9
8
|
arrayOfArrays.push(arrayToSlice.slice(i,i+size));
|
package/src/util/traccar.js
CHANGED
|
@@ -74,15 +74,18 @@ async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getS
|
|
|
74
74
|
if(getSummary) url += `&type=summary`
|
|
75
75
|
console.log('LOADING_MESSAGE:' + devices.map(d => d.name).join(', '))
|
|
76
76
|
|
|
77
|
-
const sliced = automaticReports.sliceArray(devices)
|
|
77
|
+
const sliced = automaticReports.sliceArray(devices, 50)
|
|
78
78
|
let deviceCount = 0
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
const result = []
|
|
80
|
+
for(const chunk of sliced) {
|
|
81
|
+
const requests = chunk.map(d =>
|
|
82
|
+
traccar.axios.get(url + '&' + `deviceId=${d.id}`).then(r => r.data).then(x => {
|
|
83
|
+
console.log('LOADING_MESSAGE:' + d.name)
|
|
84
|
+
console.log(`PROGRESS_PERC:${++deviceCount / devices.length * 100}`)
|
|
85
|
+
return x
|
|
86
|
+
}))
|
|
87
|
+
result.push(...(await Promise.all(requests)))
|
|
88
|
+
}
|
|
86
89
|
return {
|
|
87
90
|
route: result.filter(t => t.route).map(r => r.route).flat(),
|
|
88
91
|
trips: result.filter(t => t.trips).map(r => r.trips).flat(),
|