fleetmap-reports 2.0.223 → 2.0.225
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/tests/index.js +1 -0
- package/src/zone-report.js +20 -6
package/package.json
CHANGED
package/src/tests/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const traccarConfig = {
|
|
|
10
10
|
}
|
|
11
11
|
const axios = require('axios').create({ ...traccarConfig.baseOptions, baseURL: traccarConfig.basePath })
|
|
12
12
|
process.env.TRACCAR_API_REPORTS = 'https://ltqgfyvcklxzaonv7h4rlmghai0rszop.lambda-url.us-east-1.on.aws/api'
|
|
13
|
+
process.env.SERVER_HOST = 'api.pinme.io'
|
|
13
14
|
const getReports = async (email, password) => {
|
|
14
15
|
try {
|
|
15
16
|
email = email || process.env.email
|
package/src/zone-report.js
CHANGED
|
@@ -22,7 +22,7 @@ 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
|
|
|
@@ -84,12 +84,26 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
84
84
|
const sliced = automaticReports.sliceArray(devices, sliceSize)
|
|
85
85
|
|
|
86
86
|
let deviceCount = 0
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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 => {
|
|
99
|
+
console.log(url, 'done')
|
|
100
|
+
return response.data
|
|
101
|
+
}).catch(e => console.error(e.message, e.response?.data))
|
|
102
|
+
)
|
|
103
|
+
const results = await Promise.all(promises)
|
|
104
|
+
results.forEach(processed => {
|
|
90
105
|
allData.devices.push(...processed)
|
|
91
|
-
|
|
92
|
-
}
|
|
106
|
+
})
|
|
93
107
|
|
|
94
108
|
reportData.push(allData)
|
|
95
109
|
|