fleetmap-reports 1.0.476 → 1.0.477

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.476",
3
+ "version": "1.0.477",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.test.js CHANGED
@@ -25,8 +25,8 @@ describe('Test_Reports', function () {
25
25
  const { device, totalDistance, totalEventTime } = await getSpeedingReport(report, userData)
26
26
  assert.equal(device.alerts.length, 11) // Total Alerts
27
27
  console.log(device.alerts)
28
- assert.equal(totalDistance, 74.71054403083238) // Total Kms
29
- assert.equal(totalEventTime, 3009000) // Total Duration
28
+ assert.equal(totalDistance, 113.82700635835963) // Total Kms
29
+ assert.equal(totalEventTime, 5258000) // Total Duration
30
30
  }, 200000)
31
31
  // eslint-disable-next-line no-undef
32
32
  it('Speeding with custom speed', async () => {
@@ -222,7 +222,7 @@ async function findEventsPosition (from, to, devices, events, routes, userData)
222
222
  const positions = routes.filter(p => p.deviceId === d.id)
223
223
 
224
224
  for (const a of deviceEvents) {
225
- let pIndex = positions.findIndex(p => p.id === a.positionId)
225
+ const pIndex = positions.findIndex(p => p.id === a.positionId)
226
226
  if (pIndex > 0) {
227
227
  let geofence = null
228
228
  if (a.geofenceId) {
@@ -233,8 +233,11 @@ async function findEventsPosition (from, to, devices, events, routes, userData)
233
233
  }
234
234
 
235
235
  a.position = positions[pIndex]
236
- pIndex = calculateEventData(positions, pIndex, a, d, geofence, userData)
237
- positions.slice(pIndex)
236
+ // TODO: we should user something else
237
+ // the linkId property exists when speed events come from here, in that case the data is already calculated
238
+ if (!d.linkId) {
239
+ calculateEventData(positions, pIndex, a, d, geofence, userData)
240
+ }
238
241
  }
239
242
  }
240
243
  }