fleetmap-reports 1.0.922 → 1.0.924
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/kms-report.js +2 -2
- package/src/tests/zones.test.js +8 -9
- package/src/util/utils.js +3 -2
package/package.json
CHANGED
package/src/kms-report.js
CHANGED
|
@@ -58,8 +58,8 @@ async function createKmsReportByDevice (from, to, userData, traccarInstance) {
|
|
|
58
58
|
|
|
59
59
|
// Process report data
|
|
60
60
|
if (trips.length) {
|
|
61
|
-
checkTripsKms(traccarInstance, from, to,
|
|
62
|
-
allData.devices = allData.devices.concat(await processDevices(from, to,
|
|
61
|
+
checkTripsKms(traccarInstance, from, to, devices, { trips, route })
|
|
62
|
+
allData.devices = allData.devices.concat(await processDevices(from, to, devices, {
|
|
63
63
|
trips,
|
|
64
64
|
route
|
|
65
65
|
}, userData, traccarInstance))
|
package/src/tests/zones.test.js
CHANGED
|
@@ -45,19 +45,18 @@ describe('zones', function () {
|
|
|
45
45
|
|
|
46
46
|
// eslint-disable-next-line no-undef
|
|
47
47
|
it('works with casais zones in columns', async () => {
|
|
48
|
-
const report = await getReports(
|
|
48
|
+
const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
|
|
49
49
|
const userData = await report.getUserData()
|
|
50
50
|
userData.zonesByColumn = true
|
|
51
|
-
userData.devices = userData.devices.filter(d => d.
|
|
52
|
-
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde '
|
|
53
|
-
|
|
54
|
-
userData.onlyWithKmsOut = false
|
|
51
|
+
userData.devices = userData.devices.filter(d => d.name === 'G-1101-E Clio')
|
|
52
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ')
|
|
53
|
+
userData.onlyWithKmsOut = true
|
|
55
54
|
const result = await report.zoneReport(
|
|
56
|
-
new Date(Date.UTC(2023,
|
|
57
|
-
new Date(Date.UTC(2023,
|
|
55
|
+
new Date(Date.UTC(2023, 0, 1, 0, 0, 0, 0)),
|
|
56
|
+
new Date(Date.UTC(2023, 0, 31, 23, 59, 59, 0)),
|
|
58
57
|
userData)
|
|
59
|
-
const first = result[0].devices[0]
|
|
58
|
+
const first = result[0].devices[0].days[0]
|
|
60
59
|
console.log(first)
|
|
61
|
-
assert.equal(first.
|
|
60
|
+
assert.equal(first.distanceOut, 35.52274536571346)
|
|
62
61
|
}, 4000000)
|
|
63
62
|
})
|
package/src/util/utils.js
CHANGED
|
@@ -226,13 +226,14 @@ function weekDaySelected (date, weekDays) {
|
|
|
226
226
|
|
|
227
227
|
async function executeServerSide (type, allData, sliced, from, to, userData, totalDevices) {
|
|
228
228
|
let deviceCount = 0
|
|
229
|
-
|
|
229
|
+
console.log(`PROGRESS_PERC:${1 / totalDevices * 100}`)
|
|
230
|
+
await Promise.all(sliced.map(async devices => {
|
|
230
231
|
const url = `https://${process.env.SERVER_HOST}/reports/${type}`
|
|
231
232
|
const data = await axios.post(url, { from, to, userData: { ...userData, devices } }, { withCredentials: true }).then(d => d.data)
|
|
232
233
|
allData.devices.push(...(data[0].devices))
|
|
233
234
|
deviceCount = deviceCount + devices.length
|
|
234
235
|
console.log(`PROGRESS_PERC:${deviceCount / totalDevices * 100}`)
|
|
235
|
-
}
|
|
236
|
+
}))
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
exports.executeServerSide = executeServerSide
|