fleetmap-reports 1.0.845 → 1.0.847
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
|
@@ -6,6 +6,11 @@ const { convertToFeature, convertPositionToFeature } = require('../util/utils')
|
|
|
6
6
|
function calculateLastStopTime (stopTime, to, time) {
|
|
7
7
|
return stopTime + (to.getTime() - new Date(time).getTime())
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
function calculateFirstStopTime (stopTime, from, time) {
|
|
11
|
+
return stopTime + (new Date(time).getTime() - from.getTime())
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
async function createActivityReport (from, to, userData, traccarInstance) {
|
|
10
15
|
const unauthorizedGeofences = []
|
|
11
16
|
const authorizedGeofences = []
|
|
@@ -3,20 +3,18 @@ const traccarHelper = require('../util/traccar')
|
|
|
3
3
|
const distance = require('@turf/distance')
|
|
4
4
|
const { convertToLocaleString } = require('../util/utils')
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
async function createGPSJumpReport (from, to, userData, traccar) {
|
|
6
|
+
async function createGPSJumpReport (from, to, userData, traccar, minDistance) {
|
|
9
7
|
let reportData = []
|
|
10
8
|
|
|
11
9
|
const devices = userData.devices
|
|
12
10
|
|
|
13
|
-
const sliced = automaticReports.sliceArray(devices,
|
|
11
|
+
const sliced = automaticReports.sliceArray(devices, 10)
|
|
14
12
|
let deviceCount = 0
|
|
15
13
|
for (const slice of sliced) {
|
|
16
14
|
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, false, false, false, deviceCount, devices.length)
|
|
17
15
|
|
|
18
16
|
slice.forEach(d => {
|
|
19
|
-
const deviceData = getDeviceData(allInOne, d, userData.user)
|
|
17
|
+
const deviceData = getDeviceData(allInOne, d, userData.user, minDistance)
|
|
20
18
|
reportData = reportData.concat(deviceData)
|
|
21
19
|
})
|
|
22
20
|
|
|
@@ -26,7 +24,7 @@ async function createGPSJumpReport (from, to, userData, traccar) {
|
|
|
26
24
|
return reportData
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
function getDeviceData (allInOne, d, user) {
|
|
27
|
+
function getDeviceData (allInOne, d, user, minDistance) {
|
|
30
28
|
const deviceRoute = allInOne.route.filter(t => t.deviceId === d.id)
|
|
31
29
|
|
|
32
30
|
return deviceRoute.map((pA, index) => {
|
|
@@ -44,7 +42,7 @@ function getDeviceData (allInOne, d, user) {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
return undefined
|
|
47
|
-
}).filter(a => a && minDistance < a.distance)
|
|
45
|
+
}).filter(a => a && minDistance * 1000 < a.distance)
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
exports.createGPSJumpReport = createGPSJumpReport
|
|
@@ -72,14 +72,4 @@ describe('activity report', function () {
|
|
|
72
72
|
console.log(device)
|
|
73
73
|
assert.equal(device.summary.reduce((a, b) => a + b.convertedSpentFuel, 0), 168.79999999999995)
|
|
74
74
|
}, 800000)
|
|
75
|
-
it('Activity test performance', async () => {
|
|
76
|
-
const report = await getReports('q.trans', 'quality1214')
|
|
77
|
-
const userData = await report.getUserData()
|
|
78
|
-
console.log(userData)
|
|
79
|
-
userData.groupByDay = true
|
|
80
|
-
const data = await report.activityReport(new Date(2023, 7, 1, 0, 0, 0, 0),
|
|
81
|
-
new Date(2023, 31, 5, 23, 59, 59, 0),
|
|
82
|
-
userData)
|
|
83
|
-
assert.equal(data.length, 1)
|
|
84
|
-
}, 8000000)
|
|
85
75
|
})
|
package/src/tests/index.test.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const { getReports } = require('./index')
|
|
3
3
|
const assert = require('assert')
|
|
4
4
|
const utils = require('../util/utils')
|
|
5
|
-
const { createGPSJumpReport } = require('../partnerReports/gpsjump-report')
|
|
6
5
|
|
|
7
6
|
// eslint-disable-next-line no-undef
|
|
8
7
|
describe('Test_Reports', function () {
|
|
@@ -19,19 +18,12 @@ describe('Test_Reports', function () {
|
|
|
19
18
|
const pdf = await report.speedingReportToPDF(userData, data[0])
|
|
20
19
|
pdf.save()
|
|
21
20
|
}, 40000)
|
|
21
|
+
|
|
22
22
|
it('converts madrid time', async () => {
|
|
23
23
|
assert.equal(false, utils.isClientSide())
|
|
24
24
|
console.log(utils.convertToLocaleString(new Date(), 'es-CL', 'Europe/Madrid'))
|
|
25
25
|
})
|
|
26
|
-
|
|
27
|
-
const report = await getReports('HASSANE', 'movitec.1637')
|
|
28
|
-
const userData = await report.getUserData()
|
|
29
|
-
userData.devices = userData.devices.filter(d => d.id === 148725)
|
|
30
|
-
const data = await createGPSJumpReport(new Date(2023, 8, 22, 0, 0, 0, 0),
|
|
31
|
-
new Date(2023, 8, 24, 23, 59, 59, 0),
|
|
32
|
-
userData, report.traccar)
|
|
33
|
-
console.log(data)
|
|
34
|
-
}, 40000)
|
|
26
|
+
|
|
35
27
|
it('Idle by device', async () => {
|
|
36
28
|
const report = await getReports()
|
|
37
29
|
const userData = await report.getUserData()
|
|
@@ -62,7 +54,7 @@ describe('Test_Reports', function () {
|
|
|
62
54
|
const totalIdleTime = driver.idleEvents.reduce((a, b) => a + b.idleTime, 0)
|
|
63
55
|
assert.equal(driver.idleEvents.length, 15) // Total Alerts
|
|
64
56
|
assert.equal(totalIdleTime, 16000) // Total Duration
|
|
65
|
-
}, 20000)
|
|
57
|
+
}, 20000)
|
|
66
58
|
// eslint-disable-next-line no-undef
|
|
67
59
|
it('test allinone', async () => {
|
|
68
60
|
console.log('Start')
|
package/src/tests/zones.test.js
CHANGED
|
@@ -32,18 +32,6 @@ describe('zones', function () {
|
|
|
32
32
|
console.log('result', result)
|
|
33
33
|
}, 4000000)
|
|
34
34
|
|
|
35
|
-
it('works with afriquia', async () => {
|
|
36
|
-
const report = await getReports(process.env.USER_AFRIQUIA, process.env.PASS_AFRIQUIA)
|
|
37
|
-
const userData = await report.getUserData()
|
|
38
|
-
console.log(userData.devices.length)
|
|
39
|
-
console.log(userData.geofences)
|
|
40
|
-
const result = await report.zoneReport(
|
|
41
|
-
new Date(Date.UTC(2023, 5, 11, 0, 0, 0, 0)),
|
|
42
|
-
new Date(Date.UTC(2023, 5, 11, 23, 59, 59, 0)),
|
|
43
|
-
userData)
|
|
44
|
-
console.log('result', result)
|
|
45
|
-
}, 4000000)
|
|
46
|
-
|
|
47
35
|
// eslint-disable-next-line no-undef
|
|
48
36
|
it('works with casais', async () => {
|
|
49
37
|
const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
|