fleetmap-reports 2.0.218 → 2.0.220
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/util/route.js +1 -0
- package/src/util/traccar.js +10 -3
- package/src/util/traccar.worker.js +10 -3
- package/src/zone-report.js +2 -2
package/package.json
CHANGED
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()
|
|
@@ -75,7 +76,12 @@ async function getItems (traccar, u, _chunk, counter, devicesPerRequest, ignoreP
|
|
|
75
76
|
? await streamJson(traccar, u.replace('allinone', '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) {
|
|
@@ -120,7 +126,8 @@ async function getAllInOne (
|
|
|
120
126
|
sliceSize = 5,
|
|
121
127
|
devicesPerRequest = 1,
|
|
122
128
|
counter = undefined,
|
|
123
|
-
ignorePercentage = false
|
|
129
|
+
ignorePercentage = false,
|
|
130
|
+
filter) {
|
|
124
131
|
let url = `/reports/allinone?from=${from.toISOString()}&to=${to.toISOString()}`
|
|
125
132
|
if (getRoutes) url += '&type=route'
|
|
126
133
|
if (getTrips) url += '&type=trips'
|
|
@@ -136,7 +143,7 @@ async function getAllInOne (
|
|
|
136
143
|
console.log(u)
|
|
137
144
|
requests.push(
|
|
138
145
|
getItems(traccar, u, _chunk, counter, devicesPerRequest, ignorePercentage, totalDevices, currentDeviceCount,
|
|
139
|
-
!getTrips && !getStops && !getSummary)
|
|
146
|
+
!getTrips && !getStops && !getSummary, filter)
|
|
140
147
|
)
|
|
141
148
|
}
|
|
142
149
|
const now = new Date()
|
|
@@ -3,7 +3,7 @@ const { parser } = require('stream-json')
|
|
|
3
3
|
const { pick } = require('stream-json/filters/Pick')
|
|
4
4
|
const { streamArray } = require('stream-json/streamers/StreamArray')
|
|
5
5
|
const { Readable } = require('stream')
|
|
6
|
-
const { cleanPosition } = require('./route')
|
|
6
|
+
const { cleanPosition, filterPosition } = require('./route')
|
|
7
7
|
|
|
8
8
|
module.exports = async ({ url, cookie, filter }) => {
|
|
9
9
|
const now = new Date()
|
|
@@ -23,8 +23,15 @@ module.exports = async ({ url, cookie, filter }) => {
|
|
|
23
23
|
parser(),
|
|
24
24
|
streamArray() // Stream each item in the array
|
|
25
25
|
])
|
|
26
|
-
pipeline.on('data', ({ value }) =>
|
|
27
|
-
|
|
26
|
+
pipeline.on('data', ({ value }) => {
|
|
27
|
+
if (filter) {
|
|
28
|
+
if (filterPosition(value)) {
|
|
29
|
+
result.route.push(cleanPosition(value))
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
result.route.push(value)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
28
35
|
pipeline.on('end', () => resolve(result))
|
|
29
36
|
pipeline.on('error', reject)
|
|
30
37
|
})
|
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,
|
|
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)))
|