fleetmap-reports 1.0.748 → 1.0.750
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/trip-report.js +4 -1
- package/src/util/parallel.js +1 -1
- package/src/util/worker.js +1 -0
package/package.json
CHANGED
package/src/trip-report.js
CHANGED
|
@@ -114,6 +114,7 @@ async function createTripReportByGroup (from, to, userData, traccar) {
|
|
|
114
114
|
async function createTripReportByDriver (from, to, userData, traccar) {
|
|
115
115
|
const devices = await traccar.devices.devicesGet().then(d => d.data)
|
|
116
116
|
console.log(devices.length, 'devices')
|
|
117
|
+
console.log('drivers', userData.drivers)
|
|
117
118
|
|
|
118
119
|
if (!devices.length) {
|
|
119
120
|
// Empty report
|
|
@@ -227,7 +228,9 @@ async function processDrivers (from, to, userData, data) {
|
|
|
227
228
|
if (isClientSide()) {
|
|
228
229
|
idleEvents.push(...(calculateIdleEvents(userData.drivers, data.route)))
|
|
229
230
|
} else {
|
|
230
|
-
|
|
231
|
+
if (data.route.length) {
|
|
232
|
+
idleEvents.push(...(await parallel('trip-report', 'calculateIdleEvents', userData.drivers, data.route)))
|
|
233
|
+
}
|
|
231
234
|
}
|
|
232
235
|
|
|
233
236
|
userData.drivers.forEach(d => {
|
package/src/util/parallel.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.parallel = (report, method, toSlice, ...args) => {
|
|
|
18
18
|
}
|
|
19
19
|
sliced.forEach((slice) => {
|
|
20
20
|
try {
|
|
21
|
-
console.log('forking worker', workerCount++, report, method, slice)
|
|
21
|
+
console.log('forking worker', workerCount++, report, method, slice, ...args)
|
|
22
22
|
const worker = cluster.fork()
|
|
23
23
|
worker.send({
|
|
24
24
|
report,
|
package/src/util/worker.js
CHANGED
|
@@ -2,6 +2,7 @@ const path = require('path')
|
|
|
2
2
|
console.log(`worker ${process.pid} is running`, process.cwd())
|
|
3
3
|
process.on('message', async (message) => {
|
|
4
4
|
const { report, method, args } = message
|
|
5
|
+
console.log(`worker ${process.pid} is running`, process.cwd(), report, method, args)
|
|
5
6
|
const _report = require(path.resolve(__dirname, `../${report}`))
|
|
6
7
|
process.send({ result: await _report[method](...args) })
|
|
7
8
|
})
|