fleetmap-reports 1.0.819 → 1.0.820

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.819",
3
+ "version": "1.0.820",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -8,7 +8,6 @@ function sliceArray (longArray, size) {
8
8
  const arrayToSlice = longArray.slice()
9
9
 
10
10
  const arrayOfArrays = []
11
- console.log('slice', arrayToSlice.length, 'in chunks of', size)
12
11
  for (let i = 0; i < arrayToSlice.length; i += size) {
13
12
  arrayOfArrays.push(arrayToSlice.slice(i, i + size))
14
13
  }
@@ -210,13 +210,14 @@ async function processDrivers (from, to, events, routes, userData) {
210
210
 
211
211
  return driversResult
212
212
  }
213
+ const MAX_DEVICE_SPEED = 160
213
214
 
214
215
  function processDevices (from, to, devices, events, routes, userData) {
215
216
  const devicesResult = []
216
217
  findEventsPosition(from, to, devices, events, routes, userData)
217
218
 
218
219
  for (const d of devices) {
219
- const deviceEvents = events.filter(e => e.deviceId === d.id && e.position)
220
+ const deviceEvents = events.filter(e => e.deviceId === d.id && e.position).filter(e => e.position.speed < MAX_DEVICE_SPEED)
220
221
  if (deviceEvents.length > 0) {
221
222
  deviceEvents.sort((a, b) => a.positionId - b.positionId)
222
223
  devicesResult.push({
@@ -37,10 +37,12 @@ describe('speeding tests', function () {
37
37
  userData.customSpeed = false
38
38
  userData.useVehicleSpeedLimit = true
39
39
  const data = await report.speedingReport(
40
- new Date(Date.UTC(2022, 9, 22, 0, 0, 0, 0)),
41
- new Date(Date.UTC(2022, 9, 23, 23, 59, 59, 0)),
40
+ new Date(Date.UTC(2023, 7, 22, 0, 0, 0, 0)),
41
+ new Date(Date.UTC(2023, 7, 23, 23, 59, 59, 0)),
42
42
  userData)
43
- assert.equal(data[0].devices.length, 0)
43
+ console.log(data[0].devices[0].alerts.length)
44
+ console.log(data[0].devices[0].alerts)
45
+ assert.equal(data[0].devices.length, 2)
44
46
  }, 900000)
45
47
 
46
48
  // eslint-disable-next-line no-undef