fleetmap-reports 1.0.747 → 1.0.748
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/automaticReports.js +1 -1
- package/src/trip-report.js +2 -4
- package/src/util/driver.js +1 -6
- package/src/util/parallel.js +4 -0
package/package.json
CHANGED
package/src/automaticReports.js
CHANGED
|
@@ -8,7 +8,7 @@ function sliceArray (longArray, size) {
|
|
|
8
8
|
const arrayToSlice = longArray.slice()
|
|
9
9
|
|
|
10
10
|
const arrayOfArrays = []
|
|
11
|
-
console.log('slice', arrayToSlice.length, 'in', size
|
|
11
|
+
console.log('slice', arrayToSlice.length, 'in chunks of', size)
|
|
12
12
|
for (let i = 0; i < arrayToSlice.length; i += size) {
|
|
13
13
|
arrayOfArrays.push(arrayToSlice.slice(i, i + size))
|
|
14
14
|
}
|
package/src/trip-report.js
CHANGED
|
@@ -113,7 +113,7 @@ async function createTripReportByGroup (from, to, userData, traccar) {
|
|
|
113
113
|
|
|
114
114
|
async function createTripReportByDriver (from, to, userData, traccar) {
|
|
115
115
|
const devices = await traccar.devices.devicesGet().then(d => d.data)
|
|
116
|
-
console.log(devices.length)
|
|
116
|
+
console.log(devices.length, 'devices')
|
|
117
117
|
|
|
118
118
|
if (!devices.length) {
|
|
119
119
|
// Empty report
|
|
@@ -122,9 +122,7 @@ async function createTripReportByDriver (from, to, userData, traccar) {
|
|
|
122
122
|
|
|
123
123
|
const results = await reportByDriver(devices, traccar, from, to, userData, processDrivers)
|
|
124
124
|
|
|
125
|
-
const report = {
|
|
126
|
-
drivers: []
|
|
127
|
-
}
|
|
125
|
+
const report = { drivers: [] }
|
|
128
126
|
|
|
129
127
|
results.drivers.forEach(result => {
|
|
130
128
|
const driver = report.drivers.find(d => d.driver.id === result.driver.id)
|
package/src/util/driver.js
CHANGED
|
@@ -17,20 +17,15 @@ async function devicesByDriver (traccarInstance, from, to, drivers, devices) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async function reportByDriver (devices, traccar, from, to, userData, processor) {
|
|
20
|
-
const report = {
|
|
21
|
-
drivers: []
|
|
22
|
-
}
|
|
20
|
+
const report = { drivers: [] }
|
|
23
21
|
|
|
24
22
|
const sliced = automaticReports.sliceArray(devices, 5)
|
|
25
23
|
|
|
26
24
|
let deviceCount = 0
|
|
27
25
|
for (const slice of sliced) {
|
|
28
26
|
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, true, false, deviceCount, devices.length)
|
|
29
|
-
|
|
30
27
|
const results = await processor(from, to, userData, { trips: allInOne.trips, route: allInOne.route, stops: allInOne.stops })
|
|
31
|
-
|
|
32
28
|
report.drivers.push(...results)
|
|
33
|
-
|
|
34
29
|
deviceCount = deviceCount + slice.length
|
|
35
30
|
}
|
|
36
31
|
|
package/src/util/parallel.js
CHANGED
|
@@ -12,6 +12,10 @@ exports.parallel = (report, method, toSlice, ...args) => {
|
|
|
12
12
|
const _result = []
|
|
13
13
|
let done = 0
|
|
14
14
|
let workerCount = 0
|
|
15
|
+
if (!sliced.length) {
|
|
16
|
+
console.error(report, method, 'got sliced length', sliced.length, toSlice)
|
|
17
|
+
reject(new Error('0 to process'))
|
|
18
|
+
}
|
|
15
19
|
sliced.forEach((slice) => {
|
|
16
20
|
try {
|
|
17
21
|
console.log('forking worker', workerCount++, report, method, slice)
|