fleetmap-reports 2.0.23 → 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 +1 -1
- package/src/speeding-report.js +13 -5
- package/LocationReport.xlsx +0 -0
package/package.json
CHANGED
package/src/speeding-report.js
CHANGED
|
@@ -314,13 +314,16 @@ async function getRoadSpeedLimits (devices, routes, threshold, minimumMinutes =
|
|
|
314
314
|
|
|
315
315
|
exports.getRoadSpeedLimits = getRoadSpeedLimits
|
|
316
316
|
|
|
317
|
-
|
|
317
|
+
let countSuccess = 0
|
|
318
|
+
let countError = 0
|
|
319
|
+
let lastSuccessDuration
|
|
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
|
-
|
|
326
|
+
const now = new Date()
|
|
324
327
|
const {
|
|
325
328
|
// eslint-disable-next-line camelcase
|
|
326
329
|
matched_points,
|
|
@@ -348,8 +351,10 @@ async function invokeValhalla (route, i, chunk, country, threshold, results, ret
|
|
|
348
351
|
lon: p.longitude,
|
|
349
352
|
lat: p.latitude
|
|
350
353
|
}))
|
|
351
|
-
}, { timeout:
|
|
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,12 +364,15 @@ 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
|
-
console.error(e.message, '
|
|
369
|
+
console.error('retry', retry, e.message, (e.response && e.response.data) || url, 'deviceId',
|
|
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)
|
|
364
372
|
return invokeValhalla(route, i, chunk, country, threshold, results, retry)
|
|
365
373
|
} else {
|
|
366
374
|
console.error(e.message, (e.response && e.response.data) || url, 'deviceId',
|
|
367
|
-
slice[0] && slice[0].deviceId, slice[0] && slice[0].address, slice[0] && slice[0].fixTime, country, chunk)
|
|
375
|
+
slice[0] && slice[0].deviceId, slice[0] && slice[0].address, slice[0] && slice[0].fixTime, country, 'chunk', chunk)
|
|
368
376
|
}
|
|
369
377
|
}
|
|
370
378
|
}
|
package/LocationReport.xlsx
DELETED
|
Binary file
|