fleetmap-reports 2.0.226 → 2.0.227

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.226",
3
+ "version": "2.0.227",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -75,7 +75,8 @@ async function getItems (traccar, u, _chunk, counter, devicesPerRequest, ignoreP
75
75
  const x = routeOnly && !isClientSide()
76
76
  ? await streamJson(traccar, u.replace('allinone', 'route').replace('type=route', ''), filter)
77
77
  : await traccar.axios.get(u, {
78
- withCredentials: true
78
+ withCredentials: true,
79
+ timeout: 900000
79
80
  }).then(r => {
80
81
  if (filter && r.data.route) {
81
82
  r.data.route = cleanPositions(r.data.route.filter(filterPosition))
@@ -86,8 +86,9 @@ async function createZoneReport (from, to, userData, traccar) {
86
86
  let deviceCount = 0
87
87
  const url = `https://${process.env.SERVER_HOST}/pinmeapi/process-report/zone-report-processing`
88
88
 
89
- const promises = sliced.map(slice =>
90
- traccar.axios.post(url, {
89
+ const promises = sliced.map(slice => {
90
+ const now = new Date()
91
+ return traccar.axios.post(url, {
91
92
  from,
92
93
  to,
93
94
  userData,
@@ -95,14 +96,16 @@ async function createZoneReport (from, to, userData, traccar) {
95
96
  deviceCount: deviceCount++,
96
97
  devices,
97
98
  reportRangeDays
98
- }).then(response => {
99
- console.log(url, 'done')
99
+ }, { timeout: 900000 }).then(response => {
100
+ console.log(url, 'done in', new Date() - now, 'ms')
100
101
  return response.data
101
102
  }).catch(e => console.error(e.message, e.response?.data))
102
- )
103
+ })
103
104
  const results = await Promise.all(promises)
104
105
  results.forEach(processed => {
105
- allData.devices.push(...processed)
106
+ if (processed) {
107
+ allData.devices.push(...processed)
108
+ }
106
109
  })
107
110
 
108
111
  reportData.push(allData)