fleetmap-reports 2.0.265 → 2.0.267

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.265",
3
+ "version": "2.0.267",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -52,23 +52,37 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
52
52
  return { drivers: [] }
53
53
  }
54
54
 
55
- const sliced = automaticReports.sliceArray(devices, 5)
56
- const driversResult = []
55
+ const sliced = automaticReports.sliceArray(devices, 1)
56
+ const deviceCount = 0
57
+ const promises = sliced.map(slice => _process(traccar, from, to, slice, deviceCount, devices, userData))
58
+ const result = await Promise.all(promises)
59
+ return { drivers: result.flat() }
60
+ }
57
61
 
58
- for (const slice of sliced) {
59
- const allInOne = await traccarHelper.getAllInOne(
60
- traccar, from, to, slice, true, false, false, false,
61
- 0,
62
- slice.length,
63
- 5,
64
- 1,
65
- undefined,
66
- true,
67
- true
68
- )
69
- await processDrivers(from, to, userData, allInOne, driversResult)
70
- }
71
- return { drivers: driversResult }
62
+ async function _process (traccar, from, to, slice, deviceCount, devices, userData) {
63
+ const url = `https://${process.env.SERVER_HOST}/pinmeapi/process-report/get-driver-route'`
64
+ return traccar.axios.post(url, {
65
+ from,
66
+ to,
67
+ slice,
68
+ deviceCount,
69
+ devices,
70
+ userData
71
+ }).then(d => d.data)
72
+ }
73
+
74
+ async function process (traccar, from, to, slice, deviceCount, devices, userData) {
75
+ const allInOne = await traccarHelper.getAllInOne(
76
+ traccar, from, to, slice, true, false, false, false,
77
+ deviceCount,
78
+ devices.length,
79
+ 5,
80
+ 1,
81
+ undefined,
82
+ false,
83
+ true
84
+ )
85
+ await processDrivers(from, to, userData, allInOne)
72
86
  }
73
87
 
74
88
  async function createLocationReportByGroup (from, to, userData, traccar) {
@@ -175,7 +189,8 @@ function processDevices (from, to, devices, data) {
175
189
  return devicesResult
176
190
  }
177
191
 
178
- async function processDrivers (from, to, userData, data, driversResult) {
192
+ async function processDrivers (from, to, userData, data) {
193
+ const result = []
179
194
  for (const d of userData.drivers) {
180
195
  const { route } = await getDriverData(d, data, userData)
181
196
  if (route.length > 0) {
@@ -195,10 +210,10 @@ async function processDrivers (from, to, userData, data, driversResult) {
195
210
  positions: route
196
211
  }
197
212
  console.log('pushing', route.length, 'for', d.name)
198
- driversResult.push(driverData)
213
+ result.push(driverData)
199
214
  }
200
215
  }
201
- console.log(driversResult)
216
+ return result
202
217
  }
203
218
 
204
219
  async function exportLocationReportToPDF (userData, reportData) {
@@ -481,3 +496,4 @@ exports.create = createLocationReport
481
496
  exports.exportToPDF = exportLocationReportToPDF
482
497
  exports.exportToExcel = exportLocationReportToExcel
483
498
  exports.getDigitalPortValue = getDigitalPortValue
499
+ exports.process = process
@@ -79,7 +79,7 @@ function processServerSide () {
79
79
  }
80
80
 
81
81
  async function getOverspeedEvents (from, to, userData, devices, allData, traccarInstance) {
82
- const _sliced = automaticReports.sliceArray(automaticReports.sliceArray(devices, 5), 5)
82
+ const _sliced = automaticReports.sliceArray(automaticReports.sliceArray(devices, 4), 4)
83
83
  let deviceCount = 0
84
84
  const overspeedEvents = []
85
85
  for (const sliced of _sliced) {