fleetmap-reports 1.0.745 → 1.0.747

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.745",
3
+ "version": "1.0.747",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -8,6 +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, 'chunks')
11
12
  for (let i = 0; i < arrayToSlice.length; i += size) {
12
13
  arrayOfArrays.push(arrayToSlice.slice(i, i + size))
13
14
  }
@@ -23,19 +23,16 @@ const { parallel } = require('./util/parallel')
23
23
  const fileName = 'TripReport'
24
24
 
25
25
  async function createTripReport (from, to, userData, traccar) {
26
- console.log('Create TripReport')
26
+ console.log('createTripReport', from, to, userData.byDriver ? 'by driver' : userData.byGroup ? 'by group' : 'by device')
27
27
  const reportData = []
28
28
 
29
29
  if (userData.byDriver) {
30
- console.log('ByDriver')
31
30
  const report = await createTripReportByDriver(from, to, userData, traccar)
32
31
  reportData.push(report)
33
32
  } else if (userData.byGroup) {
34
- console.log('ByGroup')
35
33
  const allData = await createTripReportByGroup(from, to, userData, traccar)
36
34
  reportData.push(...allData)
37
35
  } else {
38
- console.log('ByDevice')
39
36
  const report = await createTripReportByDevice(from, to, userData, traccar)
40
37
  reportData.push(report)
41
38
  }
@@ -7,16 +7,14 @@ exports.parallel = (report, method, toSlice, ...args) => {
7
7
  return new Promise((resolve, reject) => {
8
8
  if (cluster.isPrimary) {
9
9
  console.log('master', process.pid, 'is running', process.cwd(), 'with', numCPUs, 'cpus')
10
- console.log('setupPrimary', cluster.setupPrimary({
11
- exec: path.resolve(__dirname, 'worker.js')
12
- }), __dirname, 'worker.js')
10
+ cluster.setupPrimary({ exec: path.resolve(__dirname, 'worker.js') })
13
11
  const sliced = toSlice.length > (numCPUs - 1) ? sliceArray(toSlice, toSlice.length / (numCPUs - 1)) : toSlice
14
12
  const _result = []
15
13
  let done = 0
16
14
  let workerCount = 0
17
15
  sliced.forEach((slice) => {
18
16
  try {
19
- console.log('forking worker', workerCount++, report, method, 'len', slice.length)
17
+ console.log('forking worker', workerCount++, report, method, slice)
20
18
  const worker = cluster.fork()
21
19
  worker.send({
22
20
  report,