fleetmap-reports 2.0.99 → 2.0.100

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": "2.0.99",
3
+ "version": "2.0.100",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -111,13 +111,13 @@ async function createSpeedingReportByDriver (from, to, userData, traccarInstance
111
111
  const sliced = automaticReports.sliceArray(devices, 5)
112
112
  let deviceCount = 0
113
113
  for (const slice of sliced) {
114
- const { routes, events } = await getEvents(traccarInstance, from, to, slice, userData, deviceCount, devices.length, slice.length)
114
+ const eventsByDevice = await getEvents(traccarInstance, from, to, slice, userData, deviceCount, devices.length, slice.length)
115
115
  if (processServerSide()) {
116
116
  console.log('LOADING_MESSAGE:' + slice[0].name)
117
117
  console.log(`PROGRESS_PERC:${deviceCount / devices.length * 100}`)
118
118
  }
119
- if (events && events.length > 0) {
120
- _drivers.push(...(await processDrivers(from, to, events, routes, userData)))
119
+ if (eventsByDevice && eventsByDevice.length > 0) {
120
+ _drivers.push(...(await processDrivers(from, to, eventsByDevice, userData)))
121
121
  }
122
122
  deviceCount = deviceCount + slice.length
123
123
  }
@@ -193,13 +193,11 @@ function getGeofenceSpeedLimitEvents (geofencesFeatures, routes, devices) {
193
193
  return events
194
194
  }
195
195
 
196
- async function processDrivers (from, to, events, routes, userData) {
196
+ async function processDrivers (from, to, eventsByDevice, userData) {
197
197
  const driversResult = []
198
198
 
199
- findEventsPosition(from, to, userData.devices, events, routes, userData)
200
-
201
199
  for (const d of userData.drivers) {
202
- const driverEvents = await getDriverData(d, { events }, userData).events
200
+ const driverEvents = (await getDriverData(d, { events: eventsByDevice.map(d => d.alerts).flat() }, userData)).events
203
201
  if (driverEvents.length > 0) {
204
202
  driverEvents.sort((a, b) => a.positionId - b.positionId)
205
203
  driversResult.push({
@@ -64,6 +64,20 @@ describe('speeding tests', function () {
64
64
  assert.equal(totalEventTime, 1402000) // Total Duration
65
65
  }, 999990000)
66
66
 
67
+ // eslint-disable-next-line no-undef
68
+ it('Speeding by driver', async () => {
69
+ const report = await getReports(process.env.email, process.env.password)
70
+ const userData = await report.getUserData()
71
+ userData.byDriver = true
72
+ userData.useVehicleSpeedLimit = false
73
+ userData.customSpeed = 60
74
+ const data = await report.speedingReport(
75
+ new Date(Date.UTC(2024, 4, 2, 0, 0, 0, 0)),
76
+ new Date(Date.UTC(2024, 4, 2, 23, 59, 59, 0)),
77
+ userData)
78
+ assert.equal(data.drivers[0].alerts.length, 2) // Total Alerts
79
+ }, 999990000)
80
+
67
81
  // eslint-disable-next-line no-undef
68
82
  it('detects brazil', () => {
69
83
  const p = {