fleetmap-reports 2.0.33 → 2.0.35
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 +1 -1
- package/src/tests/zones.test.js +24 -7
- package/src/util/driver.js +1 -1
- package/src/zone-report.js +2 -1
package/package.json
CHANGED
package/src/kms-report.js
CHANGED
|
@@ -117,7 +117,7 @@ async function createKmsReportByDriver (from, to, userData, traccarInstance) {
|
|
|
117
117
|
report.drivers = drivers
|
|
118
118
|
})
|
|
119
119
|
} else {
|
|
120
|
-
const results = await reportByDriver(userData.devices, traccarInstance, from, to, userData, processDrivers, { route:
|
|
120
|
+
const results = await reportByDriver(userData.devices, traccarInstance, from, to, userData, processDrivers, { route: !userData.allWeek, trips: true, stops: false, summary: false })
|
|
121
121
|
|
|
122
122
|
results.drivers.forEach(result => {
|
|
123
123
|
const driver = report.drivers.find(d => d.driver.id === result.driver.id)
|
package/src/tests/zones.test.js
CHANGED
|
@@ -32,9 +32,9 @@ describe('zones', function () {
|
|
|
32
32
|
const userData = await report.getUserData()
|
|
33
33
|
userData.tripsBetweenZones = true
|
|
34
34
|
const result = await report.zoneReport(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
new Date(Date.UTC(2024, 0, 8, 0, 0, 0, 0)),
|
|
36
|
+
new Date(Date.UTC(2024, 0, 8, 23, 59, 59, 0)),
|
|
37
|
+
userData)
|
|
38
38
|
console.log('result', result)
|
|
39
39
|
}, 4000000)
|
|
40
40
|
|
|
@@ -135,11 +135,28 @@ describe('zones', function () {
|
|
|
135
135
|
g.name === 'baliza 2 - raio amarelo')
|
|
136
136
|
userData.onlyWithKmsOut = false
|
|
137
137
|
const result = await report.zoneReport(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
new Date(Date.UTC(2023, 8, 3, 0, 0, 0, 0)),
|
|
139
|
+
new Date(Date.UTC(2023, 8, 10, 23, 59, 59, 0)),
|
|
140
|
+
userData)
|
|
141
|
+
const first = result[0].devices[0]
|
|
142
|
+
console.log(first)
|
|
143
|
+
assert.equal(first.days[1].distanceOut, 298.9872662595749)
|
|
144
|
+
}, 4000000)
|
|
145
|
+
|
|
146
|
+
it('works with casais zones in columns 6', async () => {
|
|
147
|
+
const report = await getReports()
|
|
148
|
+
const userData = await report.getUserData()
|
|
149
|
+
userData.zonesByColumn = true
|
|
150
|
+
userData.devices = userData.devices.filter(d => d.id === 81166)
|
|
151
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ' ||
|
|
152
|
+
g.name === 'baliza 2 - raio amarelo')
|
|
153
|
+
userData.onlyWithKmsOut = false
|
|
154
|
+
const result = await report.zoneReport(
|
|
155
|
+
new Date(Date.UTC(2023, 9, 1, 0, 0, 0, 0)),
|
|
156
|
+
new Date(Date.UTC(2023, 9, 27, 23, 59, 59, 0)),
|
|
157
|
+
userData)
|
|
141
158
|
const first = result[0].devices[0]
|
|
142
159
|
console.log(first)
|
|
143
|
-
assert.equal(first.days[
|
|
160
|
+
assert.equal(first.days[6].distanceOut, 867.0554430738234)
|
|
144
161
|
}, 4000000)
|
|
145
162
|
})
|
package/src/util/driver.js
CHANGED
|
@@ -56,7 +56,7 @@ function getDriverName (driverUniqueId, date, userData) {
|
|
|
56
56
|
return timeline.driverName
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const driver = userData.drivers.find(d => !d.uniqueId.localeCompare(driverUniqueId, undefined, { sensitivity: 'base' }))
|
|
59
|
+
const driver = userData.drivers ? userData.drivers.find(d => !d.uniqueId.localeCompare(driverUniqueId, undefined, { sensitivity: 'base' })) : undefined
|
|
60
60
|
|
|
61
61
|
return driver
|
|
62
62
|
? driver.name + ' ' + ((driver.attributes && driver.attributes.notes) || '')
|
package/src/zone-report.js
CHANGED
|
@@ -36,7 +36,7 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const serverHost = isClientSide() && newDomains.includes(window.location.hostname)
|
|
39
|
-
? window.location.hostname
|
|
39
|
+
? `${window.location.hostname}/pinmeapi`
|
|
40
40
|
: process.env.SERVER_HOST
|
|
41
41
|
|
|
42
42
|
if (isClientSide()) {
|
|
@@ -332,6 +332,7 @@ function calculateDistanceIn (zoneInOutDayData, deviceRoute, dayRoute, fromByDay
|
|
|
332
332
|
|
|
333
333
|
function calculateDistanceOut (zoneInOutDayData, dayRoute, fromByDay, toByDay, field, device) {
|
|
334
334
|
if (zoneInOutDayData.length) {
|
|
335
|
+
zoneInOutDayData.sort((a, b) => (a.inTime ? new Date(a.inTime.fixTime).getTime() : 0) - (b.inTime ? new Date(b.inTime.fixTime).getTime() : 0))
|
|
335
336
|
const dataInsideDay = zoneInOutDayData.filter(z => z.outTime && new Date(z.outTime.fixTime) < toByDay)
|
|
336
337
|
let distanceOut = dataInsideDay.reduce((a, b) => a + (b[field] || 0), 0)
|
|
337
338
|
|