fleetmap-reports 2.0.219 → 2.0.221
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/tests/index.js +1 -1
- package/src/util/route.js +2 -1
- package/src/util/traccar.js +8 -2
- package/src/util/traccar.worker.js +10 -4
- package/src/zone-report.js +2 -2
package/package.json
CHANGED
package/src/tests/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const traccarConfig = {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
const axios = require('axios').create({ ...traccarConfig.baseOptions, baseURL: traccarConfig.basePath })
|
|
12
|
-
|
|
12
|
+
process.env.TRACCAR_API_REPORTS = 'https://ltqgfyvcklxzaonv7h4rlmghai0rszop.lambda-url.us-east-1.on.aws/api'
|
|
13
13
|
const getReports = async (email, password) => {
|
|
14
14
|
try {
|
|
15
15
|
email = email || process.env.email
|
package/src/util/route.js
CHANGED
package/src/util/traccar.js
CHANGED
|
@@ -2,6 +2,7 @@ const automaticReports = require('../automaticReports')
|
|
|
2
2
|
const { convertFromUTC, isClientSide, convertFromLocal } = require('./utils')
|
|
3
3
|
const path = require('path')
|
|
4
4
|
const Piscina = require('piscina')
|
|
5
|
+
const {cleanPositions, filterPositions, filterPosition} = require("./route");
|
|
5
6
|
const piscina = new Piscina()
|
|
6
7
|
async function getRoute (traccar, from, to, devices) {
|
|
7
8
|
const devicesToSlice = devices.slice()
|
|
@@ -72,10 +73,15 @@ async function getItems (traccar, u, _chunk, counter, devicesPerRequest, ignoreP
|
|
|
72
73
|
totalDevices, currentDeviceCount, routeOnly, filter) {
|
|
73
74
|
try {
|
|
74
75
|
const x = routeOnly && !isClientSide()
|
|
75
|
-
? await streamJson(traccar, u.replace('allinone', 'route'), filter)
|
|
76
|
+
? await streamJson(traccar, u.replace('allinone', 'route').replace('type=route', ''), filter)
|
|
76
77
|
: await traccar.axios.get(u, {
|
|
77
78
|
withCredentials: true
|
|
78
|
-
}).then(r =>
|
|
79
|
+
}).then(r => {
|
|
80
|
+
if (filter && r.data.route) {
|
|
81
|
+
r.data.route = cleanPositions(r.data.route.filter(filterPosition))
|
|
82
|
+
}
|
|
83
|
+
return r.data
|
|
84
|
+
})
|
|
79
85
|
|
|
80
86
|
console.log('LOADING_MESSAGE:' + _chunk[0].name)
|
|
81
87
|
if (counter) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const { chain } = require('stream-chain')
|
|
2
2
|
const { parser } = require('stream-json')
|
|
3
|
-
const { pick } = require('stream-json/filters/Pick')
|
|
4
3
|
const { streamArray } = require('stream-json/streamers/StreamArray')
|
|
5
4
|
const { Readable } = require('stream')
|
|
6
|
-
const { cleanPosition } = require('./route')
|
|
5
|
+
const { cleanPosition, filterPosition } = require('./route')
|
|
7
6
|
|
|
8
7
|
module.exports = async ({ url, cookie, filter }) => {
|
|
9
8
|
const now = new Date()
|
|
@@ -23,8 +22,15 @@ module.exports = async ({ url, cookie, filter }) => {
|
|
|
23
22
|
parser(),
|
|
24
23
|
streamArray() // Stream each item in the array
|
|
25
24
|
])
|
|
26
|
-
pipeline.on('data', ({ value }) =>
|
|
27
|
-
|
|
25
|
+
pipeline.on('data', ({ value }) => {
|
|
26
|
+
if (filter) {
|
|
27
|
+
if (filterPosition(value)) {
|
|
28
|
+
result.route.push(cleanPosition(value))
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
result.route.push(value)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
28
34
|
pipeline.on('end', () => resolve(result))
|
|
29
35
|
pipeline.on('error', reject)
|
|
30
36
|
})
|
package/src/zone-report.js
CHANGED
|
@@ -30,9 +30,9 @@ const fileName = 'ZoneReport'
|
|
|
30
30
|
async function process (traccar, from, to, slice, deviceCount, devices, reportRangeDays, userData) {
|
|
31
31
|
const data = await traccarHelper.getAllInOne(
|
|
32
32
|
traccar, from, to, slice, true, false, false, false,
|
|
33
|
-
deviceCount, devices.length, sliceSize, reportRangeDays > 29 ? 1 : deviceChunk, undefined, true)
|
|
33
|
+
deviceCount, devices.length, sliceSize, reportRangeDays > 29 ? 1 : deviceChunk, undefined, false, true)
|
|
34
34
|
|
|
35
|
-
const route =
|
|
35
|
+
const route = data.route
|
|
36
36
|
const alerts = []
|
|
37
37
|
if (isClientSide()) {
|
|
38
38
|
alerts.push(...(await getInAndOutEvents(slice, cleanPositions(route), userData)))
|