fleetmap-reports 2.0.266 → 2.0.267
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 +18 -15
- package/src/speeding-report.js +1 -1
package/package.json
CHANGED
package/src/location-report.js
CHANGED
|
@@ -41,6 +41,24 @@ async function createLocationReport (from, to, userData, traccar) {
|
|
|
41
41
|
return reportData
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
async function createLocationReportByDriver (from, to, userData, traccar) {
|
|
45
|
+
// server side only
|
|
46
|
+
const url = `http://${process.env.TRACCAR_HOST}/api/devices`
|
|
47
|
+
const devices = await traccar.axios.get(url).then(d => d.data)
|
|
48
|
+
console.log(devices.length)
|
|
49
|
+
|
|
50
|
+
if (!devices.length) {
|
|
51
|
+
// Empty report
|
|
52
|
+
return { drivers: [] }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const sliced = automaticReports.sliceArray(devices, 1)
|
|
56
|
+
const deviceCount = 0
|
|
57
|
+
const promises = sliced.map(slice => _process(traccar, from, to, slice, deviceCount, devices, userData))
|
|
58
|
+
const result = await Promise.all(promises)
|
|
59
|
+
return { drivers: result.flat() }
|
|
60
|
+
}
|
|
61
|
+
|
|
44
62
|
async function _process (traccar, from, to, slice, deviceCount, devices, userData) {
|
|
45
63
|
const url = `https://${process.env.SERVER_HOST}/pinmeapi/process-report/get-driver-route'`
|
|
46
64
|
return traccar.axios.post(url, {
|
|
@@ -67,21 +85,6 @@ async function process (traccar, from, to, slice, deviceCount, devices, userData
|
|
|
67
85
|
await processDrivers(from, to, userData, allInOne)
|
|
68
86
|
}
|
|
69
87
|
|
|
70
|
-
async function createLocationReportByDriver (from, to, userData, traccar) {
|
|
71
|
-
// server side only
|
|
72
|
-
const url = `http://${process.env.TRACCAR_HOST}/api/devices`
|
|
73
|
-
const devices = await traccar.axios.get(url).then(d => d.data)
|
|
74
|
-
console.log(devices.length)
|
|
75
|
-
|
|
76
|
-
if (!devices.length) { return { drivers: [] } }
|
|
77
|
-
|
|
78
|
-
const sliced = automaticReports.sliceArray(devices, 1)
|
|
79
|
-
const deviceCount = 0
|
|
80
|
-
const promises = sliced.map(slice => _process(traccar, from, to, slice, deviceCount, devices, userData))
|
|
81
|
-
const result = await Promise.all(promises)
|
|
82
|
-
return { drivers: result.flat() }
|
|
83
|
-
}
|
|
84
|
-
|
|
85
88
|
async function createLocationReportByGroup (from, to, userData, traccar) {
|
|
86
89
|
const reportData = []
|
|
87
90
|
|
package/src/speeding-report.js
CHANGED
|
@@ -79,7 +79,7 @@ function processServerSide () {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
async function getOverspeedEvents (from, to, userData, devices, allData, traccarInstance) {
|
|
82
|
-
const _sliced = automaticReports.sliceArray(automaticReports.sliceArray(devices,
|
|
82
|
+
const _sliced = automaticReports.sliceArray(automaticReports.sliceArray(devices, 4), 4)
|
|
83
83
|
let deviceCount = 0
|
|
84
84
|
const overspeedEvents = []
|
|
85
85
|
for (const sliced of _sliced) {
|