fleetmap-reports 1.0.918 → 1.0.920
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 +4 -6
- package/src/tests/zones.test.js +8 -9
package/package.json
CHANGED
package/src/kms-report.js
CHANGED
|
@@ -50,7 +50,7 @@ async function createKmsReportByDevice (from, to, userData, traccarInstance) {
|
|
|
50
50
|
const {
|
|
51
51
|
trips,
|
|
52
52
|
route
|
|
53
|
-
} = await traccar.getAllInOne(traccarInstance, from, to, devices, needRoute, true, false, false, deviceCount, allDevices.length, 10)
|
|
53
|
+
} = await traccar.getAllInOne(traccarInstance, from, to, devices, needRoute, true, false, false, deviceCount, allDevices.length, 10, 2)
|
|
54
54
|
|
|
55
55
|
// Process report data
|
|
56
56
|
if (trips.length) {
|
|
@@ -166,17 +166,15 @@ async function processDevices (from, to, devices, data, userData, traccarInstanc
|
|
|
166
166
|
|
|
167
167
|
if (userData.groupByDay) {
|
|
168
168
|
if (trips.length > 0) {
|
|
169
|
-
const days = []
|
|
170
169
|
const trips = deviceTrips.filter(t => userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData) || isPartialInsideTimetable(t, userData, deviceRoute))
|
|
171
170
|
const dates = getDates(from, to, userData.user.attributes.timezone || getUserPartner(userData.user).timezone)
|
|
172
|
-
|
|
171
|
+
const days = await Promise.all(dates.map(async date => {
|
|
173
172
|
const { tripsByDay } = await getDataByDay(d, date, { trips }, userData, traccarInstance)
|
|
174
|
-
|
|
173
|
+
return {
|
|
175
174
|
date,
|
|
176
175
|
kms: tripsByDay.reduce((a, b) => a + b.distance, 0)
|
|
177
176
|
}
|
|
178
|
-
|
|
179
|
-
}
|
|
177
|
+
}))
|
|
180
178
|
|
|
181
179
|
devicesResult.push({
|
|
182
180
|
device: d,
|
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
|
})
|