fleetmap-reports 1.0.476 → 1.0.477
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/index.test.js +2 -2
- package/src/speeding-report.js +6 -3
package/package.json
CHANGED
package/src/index.test.js
CHANGED
|
@@ -25,8 +25,8 @@ describe('Test_Reports', function () {
|
|
|
25
25
|
const { device, totalDistance, totalEventTime } = await getSpeedingReport(report, userData)
|
|
26
26
|
assert.equal(device.alerts.length, 11) // Total Alerts
|
|
27
27
|
console.log(device.alerts)
|
|
28
|
-
assert.equal(totalDistance,
|
|
29
|
-
assert.equal(totalEventTime,
|
|
28
|
+
assert.equal(totalDistance, 113.82700635835963) // Total Kms
|
|
29
|
+
assert.equal(totalEventTime, 5258000) // Total Duration
|
|
30
30
|
}, 200000)
|
|
31
31
|
// eslint-disable-next-line no-undef
|
|
32
32
|
it('Speeding with custom speed', async () => {
|
package/src/speeding-report.js
CHANGED
|
@@ -222,7 +222,7 @@ async function findEventsPosition (from, to, devices, events, routes, userData)
|
|
|
222
222
|
const positions = routes.filter(p => p.deviceId === d.id)
|
|
223
223
|
|
|
224
224
|
for (const a of deviceEvents) {
|
|
225
|
-
|
|
225
|
+
const pIndex = positions.findIndex(p => p.id === a.positionId)
|
|
226
226
|
if (pIndex > 0) {
|
|
227
227
|
let geofence = null
|
|
228
228
|
if (a.geofenceId) {
|
|
@@ -233,8 +233,11 @@ async function findEventsPosition (from, to, devices, events, routes, userData)
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
a.position = positions[pIndex]
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
// TODO: we should user something else
|
|
237
|
+
// the linkId property exists when speed events come from here, in that case the data is already calculated
|
|
238
|
+
if (!d.linkId) {
|
|
239
|
+
calculateEventData(positions, pIndex, a, d, geofence, userData)
|
|
240
|
+
}
|
|
238
241
|
}
|
|
239
242
|
}
|
|
240
243
|
}
|