fleetmap-reports 1.0.792 → 1.0.793

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": "1.0.792",
3
+ "version": "1.0.793",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -74,16 +74,15 @@ 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
- const requests = []
77
+ async function executeServerSide (allData, sliced, from, to, userData, totalDevices) {
78
+ let deviceCount = 0
79
79
  for (const devices of sliced) {
80
80
  const url = `https://${process.env.SERVER_HOST}/reports/activity-report`
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
- }))
81
+ const data = await axios.post(url, { from, to, userData: { ...userData, devices } }, { withCredentials: true }).then(d => d.data)
82
+ allData.devices.push(...(data[0].devices))
83
+ deviceCount = deviceCount + devices.length
84
+ console.log(`PROGRESS_PERC:${deviceCount / totalDevices * 100}`)
85
85
  }
86
- await Promise.all(requests)
87
86
  }
88
87
 
89
88
  async function createActivityReportByDevice (from, to, userData, traccarInstance) {
@@ -97,7 +96,7 @@ async function createActivityReportByDevice (from, to, userData, traccarInstance
97
96
  }
98
97
 
99
98
  if (isClientSide() && allDevices.length > 200) {
100
- const sliced = automaticReports.sliceArray(allDevices, 60)
99
+ const sliced = automaticReports.sliceArray(allDevices, 50)
101
100
  await executeServerSide(allData, sliced, from, to, userData, allDevices.length)
102
101
  } else {
103
102
  let deviceCount = 0