fleetmap-reports 1.0.931 → 1.0.933
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
|
@@ -13,6 +13,11 @@ async function createGPSJumpReport (from, to, userData, traccar, minDistance) {
|
|
|
13
13
|
for (const slice of sliced) {
|
|
14
14
|
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, false, false, false, deviceCount, devices.length)
|
|
15
15
|
|
|
16
|
+
allInOne.route.forEach(p => {
|
|
17
|
+
p.distance = p.attributes.distance
|
|
18
|
+
delete p.attributes
|
|
19
|
+
})
|
|
20
|
+
|
|
16
21
|
slice.forEach(d => {
|
|
17
22
|
const deviceData = getDeviceData(allInOne, d, userData.user, minDistance)
|
|
18
23
|
reportData = reportData.concat(deviceData)
|
|
@@ -30,7 +35,10 @@ function getDeviceData (allInOne, d, user, minDistance) {
|
|
|
30
35
|
return deviceRoute.map((pA, index) => {
|
|
31
36
|
if (index < deviceRoute.length - 1) {
|
|
32
37
|
const pB = deviceRoute[index + 1]
|
|
33
|
-
|
|
38
|
+
let distanceValue = pA.distance
|
|
39
|
+
if ((minDistance * 1000) >= pA.distance) {
|
|
40
|
+
distanceValue = distance.default([pA.longitude, pA.latitude], [pB.longitude, pB.latitude], { units: 'meters' })
|
|
41
|
+
}
|
|
34
42
|
|
|
35
43
|
return {
|
|
36
44
|
device: d.name,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { getReports } = require('./index')
|
|
2
|
+
const assert = require('assert')
|
|
3
|
+
const { convertMS } = require('../util/utils')
|
|
4
|
+
const { createGPSJumpReport } = require('../partnerReports/gpsjump-report')
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line no-undef
|
|
7
|
+
describe('gpsjump', function () {
|
|
8
|
+
// eslint-disable-next-line no-undef
|
|
9
|
+
it('gpsjump report', async () => {
|
|
10
|
+
const report = await getReports()
|
|
11
|
+
const userData = await report.getUserData()
|
|
12
|
+
userData.devices = userData.devices.filter(d => d.id === 22326)
|
|
13
|
+
const data = await createGPSJumpReport(
|
|
14
|
+
new Date(Date.UTC(2023, 6, 1, 0, 0, 0, 0)),
|
|
15
|
+
new Date(Date.UTC(2023, 6, 17, 23, 59, 59, 0)),
|
|
16
|
+
userData,
|
|
17
|
+
report.traccar)
|
|
18
|
+
console.log(data)
|
|
19
|
+
assert.equal(data[0].consumption, 19.799999999999997)
|
|
20
|
+
assert.equal(data[0].distance, 326.7657)
|
|
21
|
+
assert.equal(convertMS(data[1].time * 1000, false), '08:19')
|
|
22
|
+
}, 8000000)
|
|
23
|
+
})
|