fleetmap-reports 2.0.237 → 2.0.239
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 -2
- package/src/zone-report.js +19 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetmap-reports",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.239",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"wkt": "^0.1.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"axios-debug-log": "^0.8.4",
|
|
35
34
|
"eslint": "^8.15.0",
|
|
36
35
|
"eslint-config-standard": "^17.0.0",
|
|
37
36
|
"eslint-plugin-import": "^2.26.0",
|
package/src/zone-report.js
CHANGED
|
@@ -107,7 +107,8 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
107
107
|
|
|
108
108
|
const url = 'https://api.pinme.io/pinmeapi/process-report/zone-report-processing'
|
|
109
109
|
|
|
110
|
-
const
|
|
110
|
+
const limit = simpleLimit(25)
|
|
111
|
+
const promises = sliced.map((slice, i) => limit(async () => {
|
|
111
112
|
const now = new Date()
|
|
112
113
|
return traccar.axios.post(url, {
|
|
113
114
|
from,
|
|
@@ -117,15 +118,27 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
117
118
|
deviceCount: i,
|
|
118
119
|
devices,
|
|
119
120
|
reportRangeDays
|
|
120
|
-
}, { timeout: 900000 })
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
}, { timeout: 900000 })
|
|
122
|
+
.catch(e => {
|
|
123
|
+
console.error(url, e.message, e.response?.data || e, 'try again')
|
|
124
|
+
return traccar.axios.post(url, {
|
|
125
|
+
from,
|
|
126
|
+
to,
|
|
127
|
+
userData,
|
|
128
|
+
slice,
|
|
129
|
+
deviceCount: i,
|
|
130
|
+
devices,
|
|
131
|
+
reportRangeDays
|
|
132
|
+
}, { timeout: 900000 })
|
|
133
|
+
}).then(response => {
|
|
134
|
+
console.log('processed devices', slice.map(d => d.id), 'in', new Date() - now, 'ms')
|
|
135
|
+
return response.data
|
|
136
|
+
})
|
|
124
137
|
})
|
|
125
138
|
)
|
|
126
139
|
const results = await Promise.all(promises)
|
|
127
140
|
results.forEach(processed => {
|
|
128
|
-
if (processed) {
|
|
141
|
+
if (processed && processed.length) {
|
|
129
142
|
allData.devices.push(...processed)
|
|
130
143
|
}
|
|
131
144
|
})
|