fleetmap-reports 1.0.791 → 1.0.792
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/activity-report.js +10 -17
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -74,23 +74,16 @@ async function createActivityReportByGroup (from, to, userData, traccarInstance)
|
|
|
74
74
|
return reportData
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
async function executeServerSide (allData, sliced, from, to, userData
|
|
78
|
-
|
|
77
|
+
async function executeServerSide (allData, sliced, from, to, userData) {
|
|
78
|
+
const requests = []
|
|
79
79
|
for (const devices of sliced) {
|
|
80
80
|
const url = `https://${process.env.SERVER_HOST}/reports/activity-report`
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
userData: { ...userData, devices },
|
|
86
|
-
deviceCount,
|
|
87
|
-
totalDevices,
|
|
88
|
-
sliceSize: 20
|
|
89
|
-
}, { withCredentials: true }).then(d => d.data)
|
|
90
|
-
|
|
91
|
-
allData.devices.push(...(data[0].devices))
|
|
92
|
-
deviceCount += devices.length
|
|
81
|
+
requests.push(axios.post(url, { from, to, userData: { ...userData, devices } }, { withCredentials: true }).then(d => {
|
|
82
|
+
const result = d.data
|
|
83
|
+
allData.devices.push(...(result[0].devices))
|
|
84
|
+
}))
|
|
93
85
|
}
|
|
86
|
+
await Promise.all(requests)
|
|
94
87
|
}
|
|
95
88
|
|
|
96
89
|
async function createActivityReportByDevice (from, to, userData, traccarInstance) {
|
|
@@ -104,11 +97,11 @@ async function createActivityReportByDevice (from, to, userData, traccarInstance
|
|
|
104
97
|
}
|
|
105
98
|
|
|
106
99
|
if (isClientSide() && allDevices.length > 200) {
|
|
107
|
-
const sliced = automaticReports.sliceArray(allDevices,
|
|
100
|
+
const sliced = automaticReports.sliceArray(allDevices, 60)
|
|
108
101
|
await executeServerSide(allData, sliced, from, to, userData, allDevices.length)
|
|
109
102
|
} else {
|
|
110
103
|
let deviceCount = 0
|
|
111
|
-
const sliced = automaticReports.sliceArray(allDevices,
|
|
104
|
+
const sliced = automaticReports.sliceArray(allDevices, 20)
|
|
112
105
|
for (const devices of sliced) {
|
|
113
106
|
let summaries = []
|
|
114
107
|
const needRoute = userData.groupByDay || !userData.allWeek
|
|
@@ -116,7 +109,7 @@ async function createActivityReportByDevice (from, to, userData, traccarInstance
|
|
|
116
109
|
trips,
|
|
117
110
|
route,
|
|
118
111
|
summary
|
|
119
|
-
} = await traccar.getAllInOne(traccarInstance, from, to, devices, needRoute, true, false, !userData.groupByDay, deviceCount, allDevices.length)
|
|
112
|
+
} = await traccar.getAllInOne(traccarInstance, from, to, devices, needRoute, true, false, !userData.groupByDay, deviceCount, allDevices.length, 10)
|
|
120
113
|
|
|
121
114
|
if (userData.groupByDay) {
|
|
122
115
|
console.log('trips:' + trips.length)
|