fleetmap-reports 2.0.238 → 2.0.240

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.238",
3
+ "version": "2.0.240",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -31,7 +31,6 @@
31
31
  "wkt": "^0.1.1"
32
32
  },
33
33
  "devDependencies": {
34
- "axios-debug-log": "^0.8.4",
35
34
  "eslint": "^8.15.0",
36
35
  "eslint-config-standard": "^17.0.0",
37
36
  "eslint-plugin-import": "^2.26.0",
@@ -9,7 +9,7 @@ describe('zones', function () {
9
9
  userData.tripsBetweenZones = true
10
10
  const result = await report.zoneReport(
11
11
  new Date(Date.UTC(2023, 6, 24, 0, 0, 0, 0)),
12
- new Date(Date.UTC(2023, 6, 25, 23, 59, 59, 0)),
12
+ new Date(Date.UTC(2023, 7, 25, 23, 59, 59, 0)),
13
13
  userData)
14
14
  console.log(await report.zoneReportToPDF(userData, result[0]))
15
15
  }, 4000000)
@@ -107,7 +107,7 @@ async function createZoneReport (from, to, userData, traccar) {
107
107
 
108
108
  const url = 'https://api.pinme.io/pinmeapi/process-report/zone-report-processing'
109
109
 
110
- const limit = simpleLimit(50)
110
+ const limit = simpleLimit(25)
111
111
  const promises = sliced.map((slice, i) => limit(async () => {
112
112
  const now = new Date()
113
113
  return traccar.axios.post(url, {
@@ -118,10 +118,22 @@ async function createZoneReport (from, to, userData, traccar) {
118
118
  deviceCount: i,
119
119
  devices,
120
120
  reportRangeDays
121
- }, { timeout: 900000 }).then(response => {
122
- console.log('processed devices', slice.map(d => d.id), 'in', new Date() - now, 'ms')
123
- return response.data
124
- }).catch(e => console.error(url, e.message, e))
121
+ }, { timeout: 900000 })
122
+ .catch(e => {
123
+ console.error(url, e.message, e.response?.data || e, 'try again')
124
+ return traccar.axios.post(url, {
125
+ from,
126
+ to,
127
+ userData,
128
+ slice,
129
+ deviceCount: i,
130
+ devices,
131
+ reportRangeDays
132
+ }, { timeout: 900000 })
133
+ }).then(response => {
134
+ console.log('processed devices', slice.map(d => d.id), 'in', new Date() - now, 'ms')
135
+ return response.data
136
+ })
125
137
  })
126
138
  )
127
139
  const results = await Promise.all(promises)
@@ -465,7 +477,7 @@ function analyseAlerts (alerts, deviceRoute, userData, from, to, device) {
465
477
  anyLastExit: a.anyLastExit,
466
478
  geofenceName: geofence.name,
467
479
  geofenceId: geofence.id,
468
- stopped: routeIn.filter(p => !p.attributes.ignition).length > 0,
480
+ stopped: routeIn.filter(p => !p.attributes?.ignition).length > 0,
469
481
  driverName: inData.position.driverName
470
482
  })
471
483
  zoneInData = zoneInData.filter(z => z.geofenceId !== a.geofenceId)