fleetmap-reports 2.0.276 → 2.0.277

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.276",
3
+ "version": "2.0.277",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -62,7 +62,7 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
62
62
  return { drivers: results.flat() }
63
63
  }
64
64
 
65
- async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData) {
65
+ async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData, retry = 3) {
66
66
  const url = `https://${process.env.SERVER_HOST}/pinmeapi/process-report/get-driver-route`
67
67
  return traccar.axios.post(url, {
68
68
  from,
@@ -73,17 +73,13 @@ async function _getDriverRoute (traccar, from, to, slice, deviceCount, devices,
73
73
  userData
74
74
  }, { timeout: 1000 * 60 * 5 })
75
75
  .catch((e) => {
76
- console.error('moving on', e)
77
- return traccar.axios.post(url, {
78
- from,
79
- to,
80
- slice,
81
- deviceCount,
82
- devices,
83
- userData
84
- }).then(d => d.data)
76
+ if (--retry) {
77
+ return _getDriverRoute(traccar, from, to, slice, deviceCount, devices, userData, retry)
78
+ } else {
79
+ console.error('giving up', slice[0].id, 'after 3 retries', e.message)
80
+ }
85
81
  })
86
- .then(d => d && d.data)
82
+ .then(r => r.data)
87
83
  }
88
84
 
89
85
  async function getDriverRoute (traccar, from, to, slice, deviceCount, devices, userData) {