fleetmap-reports 1.0.475 → 1.0.476

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.475",
3
+ "version": "1.0.476",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.test.js CHANGED
@@ -24,9 +24,9 @@ describe('Test_Reports', function () {
24
24
  userData.roadSpeedLimits = true
25
25
  const { device, totalDistance, totalEventTime } = await getSpeedingReport(report, userData)
26
26
  assert.equal(device.alerts.length, 11) // Total Alerts
27
- console.log(device.alerts[0])
27
+ console.log(device.alerts)
28
28
  assert.equal(totalDistance, 74.71054403083238) // Total Kms
29
- assert.equal(totalEventTime, 562000) // Total Duration
29
+ assert.equal(totalEventTime, 3009000) // Total Duration
30
30
  }, 200000)
31
31
  // eslint-disable-next-line no-undef
32
32
  it('Speeding with custom speed', async () => {
@@ -294,6 +294,8 @@ async function getHereEvents (devices, routes, threshold) {
294
294
  cur.roadSpeedLimit = cur.speedLimit
295
295
  cur.deviceId = d.id
296
296
  cur.attributes = { speedLimit: cur.speedLimit, speed: cur.currentSpeedKmh / 1.85200, maxSpeed: cur.position.speed }
297
+ cur.eventTime = 0
298
+ cur.distance = 0
297
299
  return acc.concat(cur)
298
300
  }
299
301
  }
@@ -318,7 +320,10 @@ function calculateEventData (positions, pIndex, alert, device, geofence, userDat
318
320
  let endEventPosition = alert.position
319
321
  let maxSpeed = alert.position.speed
320
322
  let dist = 0
321
- if (alert.eventTime) { return -1 }
323
+ if (alert.eventTime) {
324
+ console.log('ignoring')
325
+ return -1
326
+ }
322
327
  while (pIndex + 1 < positions.length) {
323
328
  pIndex++
324
329
  dist += distance.default(point([endEventPosition.longitude, endEventPosition.latitude]),