fleetmap-reports 2.0.222 → 2.0.224
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/zone-report.js +18 -7
package/package.json
CHANGED
package/src/zone-report.js
CHANGED
|
@@ -22,11 +22,11 @@ const { checkGeofenceIn } = require('./util/geofence')
|
|
|
22
22
|
const { parallel } = require('./util/parallel')
|
|
23
23
|
const { getDataByDay } = require('./util/trips')
|
|
24
24
|
const axios = require('axios').default
|
|
25
|
-
const sliceSize =
|
|
25
|
+
const sliceSize = 1
|
|
26
26
|
const deviceChunk = 5
|
|
27
27
|
const fileName = 'ZoneReport'
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
exports.process = async (traccar, from, to, slice, deviceCount, devices, reportRangeDays, userData) => {
|
|
30
30
|
const data = await traccarHelper.getAllInOne(
|
|
31
31
|
traccar, from, to, slice, true, false, false, false,
|
|
32
32
|
deviceCount, devices.length, sliceSize, reportRangeDays > 29 ? 1 : deviceChunk, undefined, false, true)
|
|
@@ -84,12 +84,23 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
84
84
|
const sliced = automaticReports.sliceArray(devices, sliceSize)
|
|
85
85
|
|
|
86
86
|
let deviceCount = 0
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
const url = `https://${process.env.SERVER_HOST}/pinmeapi/reports/zone-report-processing`
|
|
88
|
+
|
|
89
|
+
const promises = sliced.map(slice =>
|
|
90
|
+
traccar.axios.post(url, {
|
|
91
|
+
from,
|
|
92
|
+
to,
|
|
93
|
+
userData,
|
|
94
|
+
slice,
|
|
95
|
+
deviceCount: deviceCount++,
|
|
96
|
+
devices,
|
|
97
|
+
reportRangeDays
|
|
98
|
+
}).then(response => response.data)
|
|
99
|
+
)
|
|
100
|
+
const results = await Promise.all(promises)
|
|
101
|
+
results.forEach(processed => {
|
|
89
102
|
allData.devices.push(...processed)
|
|
90
|
-
|
|
91
|
-
deviceCount = deviceCount + slice.length
|
|
92
|
-
}
|
|
103
|
+
})
|
|
93
104
|
|
|
94
105
|
reportData.push(allData)
|
|
95
106
|
|