fleetmap-reports 2.0.24 → 2.0.25

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": "2.0.24",
3
+ "version": "2.0.25",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -314,13 +314,16 @@ async function getRoadSpeedLimits (devices, routes, threshold, minimumMinutes =
314
314
 
315
315
  exports.getRoadSpeedLimits = getRoadSpeedLimits
316
316
 
317
+ let countSuccess = 0
318
+ let countError = 0
319
+ let lastSuccessDuration
317
320
  async function invokeValhalla (route, i, chunk, country, threshold, results, retry = 3) {
318
321
  const slice = route.slice(i, i + chunk)
319
322
  const position = slice.find(p => getCountry(p))
320
323
  let url
321
324
  try {
322
325
  url = `http://valhalla-${(position && getCountry(position)) || country}.pinme.io:8002/trace_attributes`
323
- console.log(url)
326
+ const now = new Date()
324
327
  const {
325
328
  // eslint-disable-next-line camelcase
326
329
  matched_points,
@@ -350,6 +353,8 @@ async function invokeValhalla (route, i, chunk, country, threshold, results, ret
350
353
  }))
351
354
  }, { timeout: 10000 })
352
355
  .then(r => r.data)
356
+ countSuccess++
357
+ lastSuccessDuration = new Date() - now
353
358
  // eslint-disable-next-line camelcase
354
359
  matched_points.forEach((mp, mIndex) => {
355
360
  const edge = edges[mp.edge_index]
@@ -359,9 +364,11 @@ async function invokeValhalla (route, i, chunk, country, threshold, results, ret
359
364
  }
360
365
  })
361
366
  } catch (e) {
367
+ countError++
362
368
  if (--retry) {
363
369
  console.error('retry', retry, e.message, (e.response && e.response.data) || url, 'deviceId',
364
- slice[0] && slice[0].deviceId, slice[0] && slice[0].address, slice[0] && slice[0].fixTime, country, 'chunk', chunk)
370
+ slice[0] && slice[0].deviceId, slice[0] && slice[0].address, slice[0] && slice[0].fixTime, country, 'chunk', chunk,
371
+ 'success', countSuccess, 'error', countError, lastSuccessDuration)
365
372
  return invokeValhalla(route, i, chunk, country, threshold, results, retry)
366
373
  } else {
367
374
  console.error(e.message, (e.response && e.response.data) || url, 'deviceId',
Binary file