fleetmap-reports 2.0.307 → 2.0.309
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/util/parallel.js +5 -2
- package/src/zone-report.js +1 -25
package/package.json
CHANGED
package/src/util/parallel.js
CHANGED
|
@@ -37,10 +37,13 @@ exports.parallel = (report, method, toSlice, ...args) => {
|
|
|
37
37
|
resolve(_result.flat())
|
|
38
38
|
}
|
|
39
39
|
})
|
|
40
|
-
worker.on('error',
|
|
40
|
+
worker.on('error', (e) => {
|
|
41
|
+
console.error('worker', worker.process.pid, e)
|
|
42
|
+
reject(e)
|
|
43
|
+
})
|
|
41
44
|
worker.on('exit', (code, signal) => {
|
|
42
45
|
if (code !== 0) {
|
|
43
|
-
reject(new Error(`Worker exited with code ${code} and signal ${signal}`))
|
|
46
|
+
reject(new Error(`Worker ${worker.process.pid} exited with code ${code} and signal ${signal}`))
|
|
44
47
|
}
|
|
45
48
|
})
|
|
46
49
|
} catch (e) {
|
package/src/zone-report.js
CHANGED
|
@@ -26,28 +26,6 @@ const sliceSize = 1
|
|
|
26
26
|
const deviceChunk = 5
|
|
27
27
|
const fileName = 'ZoneReport'
|
|
28
28
|
|
|
29
|
-
function simpleLimit (concurrency) {
|
|
30
|
-
const queue = []
|
|
31
|
-
let activeCount = 0
|
|
32
|
-
|
|
33
|
-
const next = () => {
|
|
34
|
-
if (queue.length === 0 || activeCount >= concurrency) return
|
|
35
|
-
activeCount++
|
|
36
|
-
const { fn, resolve, reject } = queue.shift()
|
|
37
|
-
fn().then(resolve).catch(reject).finally(() => {
|
|
38
|
-
activeCount--
|
|
39
|
-
next()
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return fn => {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
queue.push({ fn, resolve, reject })
|
|
46
|
-
next()
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
29
|
exports.process = async (traccar, from, to, slice, deviceCount, devices, reportRangeDays, userData) => {
|
|
52
30
|
const data = await traccarHelper.getAllInOne(
|
|
53
31
|
traccar, from, to, slice, true, false, false, false,
|
|
@@ -107,8 +85,7 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
107
85
|
|
|
108
86
|
const url = 'https://rntba7aqifqx3iywrenb7pq6km0liwsr.lambda-url.us-east-1.on.aws/pinmeapi/process-report/zone-report-processing'
|
|
109
87
|
|
|
110
|
-
const
|
|
111
|
-
const promises = sliced.map((slice, i) => limit(async () => {
|
|
88
|
+
const promises = sliced.map((slice, i) => {
|
|
112
89
|
const now = new Date()
|
|
113
90
|
return traccar.axios.post(url, {
|
|
114
91
|
from,
|
|
@@ -135,7 +112,6 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
135
112
|
return response.data
|
|
136
113
|
})
|
|
137
114
|
})
|
|
138
|
-
)
|
|
139
115
|
const results = await Promise.all(promises)
|
|
140
116
|
results.forEach(processed => {
|
|
141
117
|
if (processed && processed.length) {
|