fleetmap-reports 2.0.19 → 2.0.20

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.19",
3
+ "version": "2.0.20",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -89,11 +89,7 @@ async function createSpeedingReportByDevice (from, to, userData, traccarInstance
89
89
  let deviceCount = 0
90
90
  for (const sliced of _sliced) {
91
91
  await Promise.all(sliced.map(async slice => {
92
- const { routes, events } = await getEvents(traccarInstance, from, to, slice, userData, deviceCount, devices.length, slice.length)
93
- if (events.length > 0) {
94
- const devicesProcessed = processDevices(from, to, slice, events, routes, userData)
95
- allData.devices.push(...devicesProcessed)
96
- }
92
+ allData.devices = allData.devices.concat(await getEvents(traccarInstance, from, to, slice, userData, deviceCount, devices.length, slice.length, slice))
97
93
  deviceCount = deviceCount + slice.length
98
94
  if (processServerSide()) {
99
95
  console.log('LOADING_MESSAGE:' + slice[0].name)
@@ -125,7 +121,7 @@ async function createSpeedingReportByDriver (from, to, userData, traccarInstance
125
121
  return { drivers: _drivers }
126
122
  }
127
123
 
128
- async function getEvents (traccarInstance, from, to, devices, userData, deviceCount, totalDevices, sliceSize) {
124
+ async function getEvents (traccarInstance, from, to, devices, userData, deviceCount, totalDevices, sliceSize, slice) {
129
125
  if (processServerSide()) {
130
126
  const url = `https://${process.env.SERVER_HOST}/reports/speeding-report/getEvents`
131
127
  return axios.post(url, { from, to, devices, userData, deviceCount, totalDevices, sliceSize }, { withCredentials: true }).then(d => d.data)
@@ -153,7 +149,10 @@ async function getEvents (traccarInstance, from, to, devices, userData, deviceCo
153
149
  events.push(...traccarEvents)
154
150
  }
155
151
  }
156
- return { routes, events }
152
+ if (events.length > 0) {
153
+ return processDevices(from, to, slice, events, routes, userData)
154
+ }
155
+ return []
157
156
  }
158
157
  }
159
158
 
package/src/util/utils.js CHANGED
@@ -127,7 +127,7 @@ function getDates (startDate, endDate, timezone) {
127
127
  }
128
128
 
129
129
  function getImage (url) {
130
- return axios.get(url, { responseType: 'arraybuffer' }).then(d => d.data)
130
+ return require('axios').get(url, { responseType: 'arraybuffer' }).then(d => d.data)
131
131
  }
132
132
 
133
133
  async function getImageBase64 (url) {