fleetmap-reports 1.0.477 → 1.0.480

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.477",
3
+ "version": "1.0.480",
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, 113.82700635835963) // Total Kms
29
- assert.equal(totalEventTime, 5258000) // Total Duration
28
+ assert.equal(totalDistance, 74.71054403083238) // Total Kms
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 () => {
@@ -232,10 +232,8 @@ async function findEventsPosition (from, to, devices, events, routes, userData)
232
232
  }
233
233
  }
234
234
 
235
- a.position = positions[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) {
235
+ if (!userData.roadSpeedLimits) {
236
+ a.position = positions[pIndex]
239
237
  calculateEventData(positions, pIndex, a, d, geofence, userData)
240
238
  }
241
239
  }
@@ -323,10 +321,6 @@ function calculateEventData (positions, pIndex, alert, device, geofence, userDat
323
321
  let endEventPosition = alert.position
324
322
  let maxSpeed = alert.position.speed
325
323
  let dist = 0
326
- if (alert.eventTime) {
327
- console.log('ignoring')
328
- return -1
329
- }
330
324
  while (pIndex + 1 < positions.length) {
331
325
  pIndex++
332
326
  dist += distance.default(point([endEventPosition.longitude, endEventPosition.latitude]),