fleetmap-reports 1.0.846 → 1.0.849

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.846",
3
+ "version": "1.0.849",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -3,9 +3,7 @@ const traccarHelper = require('../util/traccar')
3
3
  const distance = require('@turf/distance')
4
4
  const { convertToLocaleString } = require('../util/utils')
5
5
 
6
- const minDistance = 5000
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
@@ -16,7 +14,7 @@ async function createGPSJumpReport (from, to, userData, traccar) {
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