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 +1 -1
- package/src/location-report.js +8 -6
- package/src/tests/index.js +8 -7
- package/src/tests/positions.test.js +14 -10
package/package.json
CHANGED
package/src/location-report.js
CHANGED
|
@@ -52,9 +52,14 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
|
|
|
52
52
|
return { drivers: [] }
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const
|
|
55
|
+
const sliced = automaticReports.sliceArray(devices, 4)
|
|
56
|
+
const driversResult = []
|
|
56
57
|
|
|
57
|
-
|
|
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) {
|
package/src/tests/index.js
CHANGED
|
@@ -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 (
|
|
10
|
+
const getReports = async () => {
|
|
15
11
|
try {
|
|
16
|
-
axios
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 () => {
|