fleetmap-reports 1.0.885 → 1.0.887
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 = []
|
package/src/speeding-report.js
CHANGED
|
@@ -316,6 +316,8 @@ async function getRoadSpeedLimits (devices, routes, threshold, minimumMinutes =
|
|
|
316
316
|
return method(devices, routes, threshold, minimumMinutes, country && country.code)
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
exports.getRoadSpeedLimits = getRoadSpeedLimits
|
|
320
|
+
|
|
319
321
|
async function invokeValhalla (route, i, chunk, country, threshold, results, retry = 3) {
|
|
320
322
|
const slice = route.slice(i, i + chunk)
|
|
321
323
|
try {
|
|
@@ -355,7 +357,7 @@ async function invokeValhalla (route, i, chunk, country, threshold, results, ret
|
|
|
355
357
|
const edge = edges[mp.edge_index]
|
|
356
358
|
const position = route[mIndex + i]
|
|
357
359
|
if (edge && (edge.speed_limit + (threshold || 0)) < position.speed * 1.852) {
|
|
358
|
-
results.push({ ...mp, ...edge, ...position })
|
|
360
|
+
results.push({ ...mp, ...edge, ...position, position })
|
|
359
361
|
}
|
|
360
362
|
})
|
|
361
363
|
} catch (e) {
|
|
@@ -390,7 +392,6 @@ async function getOSMSpeedingEvents (devices, routes, threshold, minimumMinutes
|
|
|
390
392
|
cur.attributes = { speedLimit: cur.speed_limit, speed: cur.speed, maxSpeed: cur.speed }
|
|
391
393
|
cur.eventTime = 0
|
|
392
394
|
cur.distance = 0
|
|
393
|
-
cur.position = { ...cur }
|
|
394
395
|
acc.push(cur)
|
|
395
396
|
}
|
|
396
397
|
return acc
|
|
@@ -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')
|
|
@@ -2,7 +2,6 @@ const { getReports } = require('./index')
|
|
|
2
2
|
const { createPerformanceReport } = require('../partnerReports/performance-report')
|
|
3
3
|
const assert = require('assert')
|
|
4
4
|
const { convertMS } = require('../util/utils')
|
|
5
|
-
const {createDailyUseReport} = require("../partnerReports/dailyuse-report");
|
|
6
5
|
// eslint-disable-next-line no-undef
|
|
7
6
|
describe('performance', function () {
|
|
8
7
|
// eslint-disable-next-line no-undef
|
|
@@ -34,15 +33,4 @@ describe('performance', function () {
|
|
|
34
33
|
console.log(data)
|
|
35
34
|
assert.equal(data[0].consumption, 168.51989999999998)
|
|
36
35
|
}, 8000000)
|
|
37
|
-
|
|
38
|
-
it('dailyuse report inofleet', async () => {
|
|
39
|
-
const report = await getReports()
|
|
40
|
-
const userData = await report.getUserData()
|
|
41
|
-
const data = await createDailyUseReport(
|
|
42
|
-
new Date(Date.UTC(2023, 9, 1, 0, 0, 0, 0)),
|
|
43
|
-
new Date(Date.UTC(2023, 9, 1, 23, 59, 59, 0)),
|
|
44
|
-
userData,
|
|
45
|
-
report.traccar)
|
|
46
|
-
console.log(data)
|
|
47
|
-
}, 8000000)
|
|
48
36
|
})
|
package/src/tests/zones.test.js
CHANGED
|
@@ -27,18 +27,6 @@ describe('zones', function () {
|
|
|
27
27
|
console.log('result', result)
|
|
28
28
|
}, 4000000)
|
|
29
29
|
|
|
30
|
-
it('works with afriquia', async () => {
|
|
31
|
-
const report = await getReports(process.env.USER_AFRIQUIA, process.env.PASS_AFRIQUIA)
|
|
32
|
-
const userData = await report.getUserData()
|
|
33
|
-
console.log(userData.devices.length)
|
|
34
|
-
console.log(userData.geofences)
|
|
35
|
-
const result = await report.zoneReport(
|
|
36
|
-
new Date(Date.UTC(2023, 5, 11, 0, 0, 0, 0)),
|
|
37
|
-
new Date(Date.UTC(2023, 5, 11, 23, 59, 59, 0)),
|
|
38
|
-
userData)
|
|
39
|
-
console.log('result', result)
|
|
40
|
-
}, 4000000)
|
|
41
|
-
|
|
42
30
|
// eslint-disable-next-line no-undef
|
|
43
31
|
it('works with casais', async () => {
|
|
44
32
|
const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
|