fleetmap-reports 2.0.259 → 2.0.261

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.259",
3
+ "version": "2.0.261",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -42,7 +42,8 @@ async function createLocationReport (from, to, userData, traccar) {
42
42
  }
43
43
 
44
44
  async function createLocationReportByDriver (from, to, userData, traccar) {
45
- const url = `https://${process.env.SERVER_HOST}/api/devices`
45
+ // server side only
46
+ const url = `http://${process.env.TRACCAR_HOST}/api/devices`
46
47
  const devices = await traccar.axios.get(url).then(d => d.data)
47
48
  console.log(devices.length)
48
49
 
@@ -51,9 +52,13 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
51
52
  return { drivers: [] }
52
53
  }
53
54
 
54
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, false, false, false)
55
+ const sliced = automaticReports.sliceArray(devices, 5)
55
56
 
56
- return { drivers: await processDrivers(from, to, userData, allInOne) }
57
+ for (const slice of sliced) {
58
+ const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, false, false, false)
59
+ await processDrivers(from, to, userData, allInOne)
60
+ }
61
+ return { drivers: driversResult }
57
62
  }
58
63
 
59
64
  async function createLocationReportByGroup (from, to, userData, traccar) {
@@ -159,9 +164,9 @@ function processDevices (from, to, devices, data) {
159
164
 
160
165
  return devicesResult
161
166
  }
167
+ const driversResult = []
162
168
 
163
169
  async function processDrivers (from, to, userData, data) {
164
- const driversResult = []
165
170
  for (const d of userData.drivers) {
166
171
  const { route } = await getDriverData(d, data, userData)
167
172
  if (route.length > 0) {
@@ -184,8 +189,6 @@ async function processDrivers (from, to, userData, data) {
184
189
  }
185
190
  }
186
191
  console.log(driversResult)
187
-
188
- return driversResult
189
192
  }
190
193
 
191
194
  async function exportLocationReportToPDF (userData, reportData) {