fleetmap-reports 2.0.260 → 2.0.262

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.260",
3
+ "version": "2.0.262",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -52,9 +52,14 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
52
52
  return { drivers: [] }
53
53
  }
54
54
 
55
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, false, false, false)
55
+ const sliced = automaticReports.sliceArray(devices, 4)
56
+ const driversResult = []
56
57
 
57
- return { drivers: await processDrivers(from, to, userData, allInOne) }
58
+ for (const slice of sliced) {
59
+ const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, false, false, false)
60
+ await processDrivers(from, to, userData, allInOne, driversResult)
61
+ }
62
+ return { drivers: driversResult }
58
63
  }
59
64
 
60
65
  async function createLocationReportByGroup (from, to, userData, traccar) {
@@ -161,8 +166,7 @@ function processDevices (from, to, devices, data) {
161
166
  return devicesResult
162
167
  }
163
168
 
164
- async function processDrivers (from, to, userData, data) {
165
- const driversResult = []
169
+ async function processDrivers (from, to, userData, data, driversResult) {
166
170
  for (const d of userData.drivers) {
167
171
  const { route } = await getDriverData(d, data, userData)
168
172
  if (route.length > 0) {
@@ -185,8 +189,6 @@ async function processDrivers (from, to, userData, data) {
185
189
  }
186
190
  }
187
191
  console.log(driversResult)
188
-
189
- return driversResult
190
192
  }
191
193
 
192
194
  async function exportLocationReportToPDF (userData, reportData) {
@@ -3,17 +3,18 @@ const { isClientSide } = require('../util/utils')
3
3
  const { newDomains } = require('fleetmap-partners')
4
4
  const serverHost = isClientSide() && newDomains.includes(window.location.hostname) ? window.location.hostname : 'api.pinme.io'
5
5
  const traccarConfig = {
6
- basePath: `https://${serverHost}/api`,
7
- baseOptions: {
8
- withCredentials: true
9
- }
6
+ basePath: `https://${serverHost}/api`
10
7
  }
11
- const axios = require('axios').create({ ...traccarConfig.baseOptions, baseURL: traccarConfig.basePath })
12
8
  process.env.TRACCAR_API_REPORTS = 'https://ltqgfyvcklxzaonv7h4rlmghai0rszop.lambda-url.us-east-1.on.aws/api'
13
9
  process.env.SERVER_HOST = 'api.pinme.io'
14
- const getReports = async (email, password) => {
10
+ const getReports = async () => {
15
11
  try {
16
- axios.defaults.headers.common.cookie = process.env.COOKIE
12
+ const axios = require('axios').create({
13
+ ...traccarConfig.baseOptions,
14
+ baseURL: traccarConfig.basePath,
15
+ headers: { cookie: process.env.COOKIE }
16
+ })
17
+
17
18
  return new Index(traccarConfig, axios)
18
19
  } catch (e) {
19
20
  console.error(e)
@@ -24,16 +24,20 @@ describe('test positions', function () {
24
24
  // eslint-disable-next-line no-undef
25
25
  it('works by driver', async () => {
26
26
  const report = await getReports()
27
- const userData = await report.getUserData()
28
- userData.byDriver = true
29
- const data = await report.locationReport(
30
- new Date(Date.UTC(2021, 11, 6, 0, 0, 0, 0)),
31
- new Date(Date.UTC(2021, 11, 9, 23, 59, 59, 0)),
32
- userData)
33
- assert.equal(data.length, 1)
34
- const driver = data[0].drivers.find(d => d.driver.id === 14020)
35
- console.log(driver.positions)
36
- assert.equal(driver.positions.length, 85) // Total Positions
27
+ try {
28
+ const userData = await report.getUserData()
29
+ userData.byDriver = true
30
+ const data = await report.locationReport(
31
+ new Date(Date.UTC(2021, 11, 6, 0, 0, 0, 0)),
32
+ new Date(Date.UTC(2021, 11, 9, 23, 59, 59, 0)),
33
+ userData)
34
+ assert.equal(data.length, 1)
35
+ const driver = data[0].drivers.find(d => d.driver.id === 14020)
36
+ console.log(driver.positions)
37
+ assert.equal(driver.positions.length, 85) // Total Positions
38
+ } catch (e) {
39
+ console.error(e)
40
+ }
37
41
  }, 20000)
38
42
  // eslint-disable-next-line no-undef
39
43
  it('works with sensores', async () => {