fleetmap-reports 1.0.911 → 1.0.915
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/speeding-report.js +4 -2
- package/src/tests/zones.test.js +8 -7
- package/src/zone-report.js +3 -2
package/package.json
CHANGED
package/src/speeding-report.js
CHANGED
|
@@ -628,7 +628,8 @@ function exportSpeedingReportToExcel (userData, reportData) {
|
|
|
628
628
|
{ label: translations.report.distance, value: 'distance' },
|
|
629
629
|
{ label: translations.report.maxSpeed, value: 'maxSpeed' },
|
|
630
630
|
{ label: translations.report.duration, value: 'duration' },
|
|
631
|
-
userData.byDriver ? { label: translations.report.vehicle, value: 'name' } : { label: translations.report.driver, value: 'driver' }
|
|
631
|
+
userData.byDriver ? { label: translations.report.vehicle, value: 'name' } : { label: translations.report.driver, value: 'driver' },
|
|
632
|
+
{ label: 'link', value: 'link', format: 'hyperlink' }
|
|
632
633
|
]
|
|
633
634
|
|
|
634
635
|
if (userData.roadSpeedLimits) {
|
|
@@ -654,7 +655,8 @@ function exportSpeedingReportToExcel (userData, reportData) {
|
|
|
654
655
|
: userData.useVehicleSpeedLimit
|
|
655
656
|
? Math.round(a.attributes.speedLimit * 1.85200)
|
|
656
657
|
: userData.customSpeed,
|
|
657
|
-
...(userData.roadSpeedLimits ? { info: `https://openstreetmap.org/way/${a.way_id}` } : {})
|
|
658
|
+
...(userData.roadSpeedLimits ? { info: `https://openstreetmap.org/way/${a.way_id}` } : {}),
|
|
659
|
+
link: `https://${getUserPartner(userData.user).host}/#/map?vehicleName=${userData.byDriver ? a.deviceName : d.device.name}&date=${new Date(a.position.fixTime).toISOString()}`
|
|
658
660
|
}
|
|
659
661
|
}))
|
|
660
662
|
})
|
package/src/tests/zones.test.js
CHANGED
|
@@ -45,18 +45,19 @@ 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('fleetmap.joao.penas2@gmail.com', 'penas46881')
|
|
49
49
|
const userData = await report.getUserData()
|
|
50
50
|
userData.zonesByColumn = true
|
|
51
|
-
userData.devices = userData.devices.filter(d => d.name === 'G-
|
|
52
|
-
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde '
|
|
51
|
+
userData.devices = userData.devices.filter(d => d.name === 'G-5983-E Clio')
|
|
52
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ' ||
|
|
53
|
+
g.name === 'baliza 2 - raio amarelo')
|
|
53
54
|
userData.onlyWithKmsOut = true
|
|
54
55
|
const result = await report.zoneReport(
|
|
55
|
-
new Date(Date.UTC(2023,
|
|
56
|
-
new Date(Date.UTC(2023,
|
|
56
|
+
new Date(Date.UTC(2023, 8, 1, 0, 0, 0, 0)),
|
|
57
|
+
new Date(Date.UTC(2023, 8, 30, 23, 59, 59, 0)),
|
|
57
58
|
userData)
|
|
58
|
-
const first = result[0].devices[0]
|
|
59
|
+
const first = result[0].devices[0]
|
|
59
60
|
console.log(first)
|
|
60
|
-
assert.equal(first.distanceOut,
|
|
61
|
+
assert.equal(first.distanceOut, 0)
|
|
61
62
|
}, 4000000)
|
|
62
63
|
})
|
package/src/zone-report.js
CHANGED
|
@@ -289,8 +289,9 @@ function calculateDistanceIn (zoneInOutDayData, deviceRoute, dayRoute, fromByDay
|
|
|
289
289
|
|
|
290
290
|
function calculateDistanceOut (zoneInOutDayData, dayRoute, fromByDay, toByDay, field, device) {
|
|
291
291
|
if (zoneInOutDayData.length) {
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
const dataInsideDay = zoneInOutDayData.filter(z => (z.inTime && new Date(z.inTime.fixTime) > fromByDay) && (z.outTime && new Date(z.outTime.fixTime) > toByDay))
|
|
293
|
+
let distanceOut = dataInsideDay.reduce((a, b) => a + (b[field] || 0), 0) -
|
|
294
|
+
(dataInsideDay.length ? (dataInsideDay[dataInsideDay.length - 1][field] || 0) : 0)
|
|
294
295
|
|
|
295
296
|
if (zoneInOutDayData[0].inTime && new Date(zoneInOutDayData[0].inTime.fixTime) > fromByDay) {
|
|
296
297
|
// Add distanceOut before the first entry
|