fleetmap-reports 1.0.753 → 1.0.755
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.
|
|
3
|
+
"version": "1.0.755",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,5 +38,8 @@
|
|
|
38
38
|
"mocha": "^10.2.0",
|
|
39
39
|
"webpack": "^5.51.0",
|
|
40
40
|
"webpack-cli": "^4.5.0"
|
|
41
|
+
},
|
|
42
|
+
"browser": {
|
|
43
|
+
"cluster": false
|
|
41
44
|
}
|
|
42
45
|
}
|
|
@@ -2,6 +2,7 @@ const { getReports } = require('./index')
|
|
|
2
2
|
const { createPerformanceReport } = require('../partnerReports/performance-report')
|
|
3
3
|
// eslint-disable-next-line no-undef
|
|
4
4
|
describe('performance', function () {
|
|
5
|
+
this.timeout(500000)
|
|
5
6
|
// eslint-disable-next-line no-undef
|
|
6
7
|
it('performance report', async () => {
|
|
7
8
|
const report = await getReports()
|
package/src/tests/zones.test.js
CHANGED
|
@@ -2,6 +2,7 @@ const { getReports } = require('./index')
|
|
|
2
2
|
const assert = require('assert')
|
|
3
3
|
// eslint-disable-next-line no-undef
|
|
4
4
|
describe('zones', function () {
|
|
5
|
+
this.timeout(500000)
|
|
5
6
|
// eslint-disable-next-line no-undef
|
|
6
7
|
it('works with ellca', async () => {
|
|
7
8
|
const report = await getReports()
|
|
@@ -47,4 +48,25 @@ describe('zones', function () {
|
|
|
47
48
|
assert.equal(first.inTime.fixTime, '2023-01-03T21:23:24.000+0000')
|
|
48
49
|
assert.equal(first.outTime.fixTime, '2023-01-07T12:22:53.000+0000')
|
|
49
50
|
}, 4000000)
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line no-undef
|
|
53
|
+
it('works with casais 2', async () => {
|
|
54
|
+
const report = await getReports('mario.andre.moreira@casais.gi', 'Casais.23')
|
|
55
|
+
const userData = await report.getUserData()
|
|
56
|
+
userData.groupByDay = true
|
|
57
|
+
userData.devices = userData.devices.filter(d => d.name === 'G-2542-F Fiat Tipo')
|
|
58
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ')
|
|
59
|
+
assert.equal(userData.geofences.length > 0, true)
|
|
60
|
+
assert.equal(userData.devices.length > 0, true)
|
|
61
|
+
const result = await report.zoneReport(
|
|
62
|
+
new Date(2023, 1, 27, 0, 0, 0, 0),
|
|
63
|
+
new Date(2023, 1, 27, 23, 59, 59, 0),
|
|
64
|
+
userData)
|
|
65
|
+
assert.equal(result[0].devices[0].geofences.length, 1)
|
|
66
|
+
assert.equal(result[0].devices[0].geofences[0].days.length, 1)
|
|
67
|
+
const first = result[0].devices[0].geofences[0].days[0]
|
|
68
|
+
assert.equal(first.firstIn, '2023-02-27T21:53:16.000+0000')
|
|
69
|
+
assert.equal(first.distanceIn, 93.03917199839687)
|
|
70
|
+
assert.equal(first.distanceOut, 819.6685737216337)
|
|
71
|
+
}, 4000000)
|
|
50
72
|
})
|
package/src/util/parallel.js
CHANGED
|
@@ -6,9 +6,10 @@ exports.parallel = (report, method, toSlice, ...args) => {
|
|
|
6
6
|
const numCPUs = require('os').cpus().length
|
|
7
7
|
return new Promise((resolve, reject) => {
|
|
8
8
|
if (cluster.isPrimary) {
|
|
9
|
-
console.log('
|
|
9
|
+
console.log('parallel with', numCPUs, 'cpus', 'toSlice len', toSlice.length)
|
|
10
10
|
cluster.setupPrimary({ exec: path.resolve(__dirname, 'worker.js') })
|
|
11
11
|
const sliced = toSlice.length > (numCPUs - 1) ? sliceArray(toSlice, toSlice.length / (numCPUs - 1)) : [toSlice]
|
|
12
|
+
console.log('sliced in', sliced.length)
|
|
12
13
|
const _result = []
|
|
13
14
|
let done = 0
|
|
14
15
|
let workerCount = 0
|
|
@@ -17,6 +18,10 @@ exports.parallel = (report, method, toSlice, ...args) => {
|
|
|
17
18
|
reject(new Error('0 to process'))
|
|
18
19
|
}
|
|
19
20
|
sliced.forEach((slice) => {
|
|
21
|
+
if (!slice.length) {
|
|
22
|
+
console.error(report, method, 'got empty slice', slice)
|
|
23
|
+
reject(new Error('got empty slice'))
|
|
24
|
+
}
|
|
20
25
|
try {
|
|
21
26
|
console.log('forking worker', workerCount++, report, method, slice)
|
|
22
27
|
const worker = cluster.fork()
|
|
@@ -37,7 +42,6 @@ exports.parallel = (report, method, toSlice, ...args) => {
|
|
|
37
42
|
reject(e)
|
|
38
43
|
}
|
|
39
44
|
})
|
|
40
|
-
|
|
41
45
|
cluster.on('exit', (worker, code, signal) => {
|
|
42
46
|
console.log('worker died', worker.process.pid, code, signal)
|
|
43
47
|
if (signal === 'SIGKILL') {
|