fleetmap-reports 1.0.292 → 1.0.297

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.292",
3
+ "version": "1.0.297",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -242,9 +242,10 @@ async function getHereEvents(devices, routes, threshold){
242
242
  console.log('no positions on device', d.name)
243
243
  continue
244
244
  }
245
+ let hereAlerts = null
245
246
  try {
246
247
  const results = await here.routeMatch(positions)
247
- const hereAlerts = results.filter(r => r.currentSpeedKmh > (parseInt(r.speedLimit) + threshold)).map(r => {
248
+ hereAlerts = results.filter(r => r.currentSpeedKmh > (parseInt(r.speedLimit) + threshold)).map(r => {
248
249
  const position = positions.find(p => new Date(p.fixTime).getTime() === r.timestamp)
249
250
  return {
250
251
  ...r,
@@ -259,7 +260,7 @@ async function getHereEvents(devices, routes, threshold){
259
260
  console.log('empty array after filter on device', d.name)
260
261
  continue
261
262
  }
262
- const reduced = hereAlerts.reduce((acc, cur, idx, src) => {
263
+ const reduced = hereAlerts.length < 2 ? hereAlerts : hereAlerts.reduce((acc, cur, idx, src) => {
263
264
  if (idx === 1) {
264
265
  return [cur]
265
266
  }
@@ -270,7 +271,7 @@ async function getHereEvents(devices, routes, threshold){
270
271
  })
271
272
  events.push(...reduced)
272
273
  } catch (e) {
273
- console.error(e)
274
+ console.error(hereAlerts, 'threshold', threshold, e)
274
275
  }
275
276
  }
276
277
  return events
@@ -482,7 +483,6 @@ function exportSpeedingReportToExcel(userData, reportData) {
482
483
  }
483
484
  }))
484
485
  })
485
- console.log(data)
486
486
  return {
487
487
  headers,
488
488
  data,