fleetmap-reports 1.0.474 → 1.0.475

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.474",
3
+ "version": "1.0.475",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.test.js CHANGED
@@ -8,8 +8,10 @@ async function getSpeedingReport (report, userData) {
8
8
  userData)
9
9
  assert.equal(data.length, 1)
10
10
  const device = data[0].devices[0]
11
+ console.log(device)
11
12
  const totalDistance = device.alerts.reduce((a, b) => a + b.distance, 0)
12
13
  const totalEventTime = device.alerts.reduce((a, b) => a + b.eventTime, 0)
14
+ console.log(device.alerts)
13
15
  return { device, totalDistance, totalEventTime }
14
16
  }
15
17
 
@@ -21,8 +23,9 @@ describe('Test_Reports', function () {
21
23
  const userData = await report.getUserData()
22
24
  userData.roadSpeedLimits = true
23
25
  const { device, totalDistance, totalEventTime } = await getSpeedingReport(report, userData)
24
- assert.equal(device.alerts.length, 15) // Total Alerts
25
- assert.equal(totalDistance, 19.59984677533689) // Total Kms
26
+ assert.equal(device.alerts.length, 11) // Total Alerts
27
+ console.log(device.alerts[0])
28
+ assert.equal(totalDistance, 74.71054403083238) // Total Kms
26
29
  assert.equal(totalEventTime, 562000) // Total Duration
27
30
  }, 200000)
28
31
  // eslint-disable-next-line no-undef
@@ -287,13 +287,13 @@ async function getHereEvents (devices, routes, threshold) {
287
287
  cur.position = positions.find(p => new Date(p.fixTime).getTime() === cur.timestamp)
288
288
  if (previous && previous.speedLimit === cur.speedLimit) {
289
289
  previous.eventTime += cur.timestamp - previous.timestamp
290
- previous.attributes.maxSpeed = Math.max(previous.attributes.maxSpeed, cur.currentSpeedKmh)
290
+ previous.attributes.maxSpeed = Math.max(previous.attributes.maxSpeed, cur.position.speed)
291
291
  previous.distance += distance.default(point([cur.position.longitude, cur.position.latitude]), point([previous.position.longitude, previous.position.latitude]))
292
292
  } else {
293
293
  cur.positionId = cur.position && cur.position.id
294
294
  cur.roadSpeedLimit = cur.speedLimit
295
295
  cur.deviceId = d.id
296
- cur.attributes = { speedLimit: cur.speedLimit, speed: cur.currentSpeedKmh / 1.85200 }
296
+ cur.attributes = { speedLimit: cur.speedLimit, speed: cur.currentSpeedKmh / 1.85200, maxSpeed: cur.position.speed }
297
297
  return acc.concat(cur)
298
298
  }
299
299
  }