fleetmap-reports 2.0.195 → 2.0.196
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 +3 -2
- package/src/util/traccar.js +20 -9
- package/src/zone-report.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetmap-reports",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.196",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
"@turf/distance": "^6.5.0",
|
|
15
15
|
"@turf/helpers": "^6.5.0",
|
|
16
16
|
"@turf/point-to-line-distance": "^6.5.0",
|
|
17
|
-
"axios": "1.
|
|
17
|
+
"axios": "1.8.2",
|
|
18
18
|
"country-reverse-geocoding": "^0.2.2",
|
|
19
19
|
"docx": "^7.3.0",
|
|
20
20
|
"file-saver": "^2.0.5",
|
|
21
21
|
"fleetmap-partners": "1.0.185",
|
|
22
22
|
"json-as-xlsx": "2.5.6",
|
|
23
|
+
"JSONStream": "^1.3.5",
|
|
23
24
|
"jspdf": "^2.5.1",
|
|
24
25
|
"jspdf-autotable": "3.8.1",
|
|
25
26
|
"moment": "2.30.1",
|
package/src/util/traccar.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const automaticReports = require('../automaticReports')
|
|
2
2
|
const { convertFromUTC, isClientSide, convertFromLocal } = require('./utils')
|
|
3
|
+
const { parse } = require('JSONStream')
|
|
3
4
|
|
|
4
5
|
async function getRoute (traccar, from, to, devices) {
|
|
5
6
|
const devicesToSlice = devices.slice()
|
|
@@ -98,15 +99,25 @@ async function getAllInOne (
|
|
|
98
99
|
traccar.axios.get(u, {
|
|
99
100
|
jar: traccar.cookieJar,
|
|
100
101
|
withCredentials: true,
|
|
101
|
-
timeout: 900000
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
timeout: 900000,
|
|
103
|
+
responseType: 'stream'
|
|
104
|
+
}).then(r => {
|
|
105
|
+
const stream = r.data
|
|
106
|
+
const jsonStream = parse()
|
|
107
|
+
stream.pipe(jsonStream)
|
|
108
|
+
let responseData = []
|
|
109
|
+
jsonStream.on('data', data => {
|
|
110
|
+
responseData = data
|
|
108
111
|
})
|
|
109
|
-
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
jsonStream.on('close', data => {
|
|
114
|
+
resolve(responseData)
|
|
115
|
+
})
|
|
116
|
+
jsonStream.on('error', err => {
|
|
117
|
+
reject(err)
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
}).then(x => {
|
|
110
121
|
console.log('LOADING_MESSAGE:' + _chunk[0].name)
|
|
111
122
|
if (counter) {
|
|
112
123
|
counter.count += devicesPerRequest
|
|
@@ -124,7 +135,7 @@ async function getAllInOne (
|
|
|
124
135
|
try {
|
|
125
136
|
result.push(...(await Promise.all(requests)))
|
|
126
137
|
} catch (e) {
|
|
127
|
-
console.
|
|
138
|
+
console.error('parallel', e.message, e.config)
|
|
128
139
|
}
|
|
129
140
|
console.log('took', new Date() - now, 'ms')
|
|
130
141
|
}
|
package/src/zone-report.js
CHANGED
|
@@ -23,7 +23,7 @@ const { checkGeofenceIn } = require('./util/geofence')
|
|
|
23
23
|
const { parallel } = require('./util/parallel')
|
|
24
24
|
const { getDataByDay } = require('./util/trips')
|
|
25
25
|
const axios = require('axios').default
|
|
26
|
-
const sliceSize =
|
|
26
|
+
const sliceSize = 4
|
|
27
27
|
const fileName = 'ZoneReport'
|
|
28
28
|
|
|
29
29
|
async function createZoneReport (from, to, userData, traccar) {
|