fleetmap-reports 1.0.384 → 1.0.385
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/trip-report.js +1 -2
- package/src/util/traccar.js +5 -1
package/package.json
CHANGED
package/src/trip-report.js
CHANGED
|
@@ -46,7 +46,7 @@ async function createTripReportByDevice(from, to, userData, traccar) {
|
|
|
46
46
|
|
|
47
47
|
let deviceCount = 0
|
|
48
48
|
for(const slice of sliced) {
|
|
49
|
-
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, true, false)
|
|
49
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, true, false, deviceCount, devices.length)
|
|
50
50
|
const tripsData = allInOne.trips
|
|
51
51
|
const stopsData = allInOne.stops
|
|
52
52
|
const routeData = allInOne.route
|
|
@@ -62,7 +62,6 @@ async function createTripReportByDevice(from, to, userData, traccar) {
|
|
|
62
62
|
}, userData))
|
|
63
63
|
}
|
|
64
64
|
deviceCount = deviceCount + slice.length
|
|
65
|
-
console.log(`PROGRESS_PERC:${deviceCount / devices.length * 100}`)
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
return allData
|
package/src/util/traccar.js
CHANGED
|
@@ -65,7 +65,7 @@ async function getSummary(traccar, from, to, devices){
|
|
|
65
65
|
return result.map(r => r.data).flat()
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getStops, getSummary){
|
|
68
|
+
async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getStops, getSummary, currentDeviceCount = 0, totalDevices = devices.length){
|
|
69
69
|
let url = `/reports/allinone?&from=${from.toISOString()}&to=${to.toISOString()}`
|
|
70
70
|
if(getRoutes) url += `&type=route`
|
|
71
71
|
if(getTrips) url += `&type=trips`
|
|
@@ -74,6 +74,7 @@ async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getS
|
|
|
74
74
|
|
|
75
75
|
const sliced = automaticReports.sliceArray(devices, 5)
|
|
76
76
|
const result = []
|
|
77
|
+
let deviceCount = currentDeviceCount
|
|
77
78
|
for(const chunk of sliced) {
|
|
78
79
|
const requests = chunk.map(d =>
|
|
79
80
|
traccar.axios.get(url + '&' + `deviceId=${d.id}`, {
|
|
@@ -81,6 +82,9 @@ async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getS
|
|
|
81
82
|
withCredentials: true
|
|
82
83
|
}).then(r => r.data).then(x => {
|
|
83
84
|
console.log('LOADING_MESSAGE:' + d.name)
|
|
85
|
+
|
|
86
|
+
deviceCount = deviceCount + 1
|
|
87
|
+
console.log(`PROGRESS_PERC:${deviceCount / totalDevices * 100}`)
|
|
84
88
|
return x
|
|
85
89
|
}))
|
|
86
90
|
result.push(...(await Promise.all(requests)))
|