fleetmap-reports 2.0.261 → 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 +4 -4
- 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,11 +52,12 @@ async function createLocationReportByDriver (from, to, userData, traccar) {
|
|
|
52
52
|
return { drivers: [] }
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const sliced = automaticReports.sliceArray(devices,
|
|
55
|
+
const sliced = automaticReports.sliceArray(devices, 4)
|
|
56
|
+
const driversResult = []
|
|
56
57
|
|
|
57
58
|
for (const slice of sliced) {
|
|
58
59
|
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, false, false, false)
|
|
59
|
-
await processDrivers(from, to, userData, allInOne)
|
|
60
|
+
await processDrivers(from, to, userData, allInOne, driversResult)
|
|
60
61
|
}
|
|
61
62
|
return { drivers: driversResult }
|
|
62
63
|
}
|
|
@@ -164,9 +165,8 @@ function processDevices (from, to, devices, data) {
|
|
|
164
165
|
|
|
165
166
|
return devicesResult
|
|
166
167
|
}
|
|
167
|
-
const driversResult = []
|
|
168
168
|
|
|
169
|
-
async function processDrivers (from, to, userData, data) {
|
|
169
|
+
async function processDrivers (from, to, userData, data, driversResult) {
|
|
170
170
|
for (const d of userData.drivers) {
|
|
171
171
|
const { route } = await getDriverData(d, data, userData)
|
|
172
172
|
if (route.length > 0) {
|
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 () => {
|