fleetmap-reports 1.0.399 → 1.0.402

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/src/index.test.js CHANGED
@@ -48,6 +48,8 @@ describe('Test_Reports', function () {
48
48
  assert.equal(data.length, 1)
49
49
  const device = data[0].devices.find(d => d.device.id === 22326)
50
50
  assert.equal(device.trips.length, 7) // Total Trips
51
+ assert.equal(device.trips[0].endPOIName, 'Casa João')
52
+ assert.equal(device.trips[1].endPOIName, undefined)
51
53
  assert.equal(device.totalDistance, 339204.53999999166) // Total Kms
52
54
  }, 20000)
53
55
  // eslint-disable-next-line no-undef
@@ -271,7 +273,7 @@ describe('Test_Reports', function () {
271
273
  assert.equal(tripsReport.length, 1)
272
274
  const device1 = tripsReport[0].devices.find(d => d.device.id === 11681)
273
275
  assert.equal(device1.trips.length, 44) // Total Trips
274
- assert.equal(device1.totalDistance, 882.801081530881) // Total Kms
276
+ assert.equal(device1.totalDistance, 882801.0815308811) // Total Kms
275
277
 
276
278
  const device2 = kmsReport[0].devices.find(d => d.device.id === 11681)
277
279
  assert.equal(device2.summary.distance, device1.totalDistance) // Total Kms
@@ -12,7 +12,7 @@ const traccarHelper = require('./util/traccar')
12
12
  const { devicesToProcess } = require('./util/device')
13
13
  const turf = require('@turf/distance')
14
14
  const { point } = require('@turf/helpers')
15
- const distance = require('@turf/distance');
15
+ const distance = require('@turf/distance')
16
16
 
17
17
  const fileName = 'SpeedingReport'
18
18
  const eventTypes = ['deviceOverspeed']
@@ -73,14 +73,15 @@ async function createSpeedingReportByDevice (from, to, userData, traccarInstance
73
73
  const allInOne = await traccarHelper.getAllInOne(traccarInstance, from, to, devices, true, false, false, false)
74
74
  const routes = allInOne.route
75
75
  const events = []
76
- if (!userData.useVehicleSpeedLimit && userData.customSpeed) {
77
- events.push(...await getCustomSpeedLimitEvents(devices, routes, userData.customSpeed))
78
- } else {
79
- events.push(...await traccarHelper.getEvents(traccarInstance, from, to, devices, eventTypes))
80
- }
81
76
 
82
77
  if (userData.roadSpeedLimits) {
83
78
  events.push(...await getHereEvents(devices, routes, userData.maxSpeedThreshold))
79
+ } else {
80
+ if (!userData.useVehicleSpeedLimit && userData.customSpeed) {
81
+ events.push(...await getCustomSpeedLimitEvents(devices, routes, userData.customSpeed))
82
+ } else {
83
+ events.push(...await traccarHelper.getEvents(traccarInstance, from, to, devices, eventTypes))
84
+ }
84
85
  }
85
86
 
86
87
  if (!events.length) {