fleetmap-reports 2.0.35 → 2.0.36
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/util/driver.js +6 -13
package/package.json
CHANGED
package/src/util/driver.js
CHANGED
|
@@ -6,20 +6,13 @@ const { isInsideTimetable, isPartialInsideTimetable } = require('./trips')
|
|
|
6
6
|
// get devices used by each driver between two dates
|
|
7
7
|
async function devicesByDriver (traccarInstance, from, to, drivers, devices) {
|
|
8
8
|
const eventsData = await traccar.getEvents(traccarInstance, from, to, devices, ['driverChanged'])
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
for (const d of drivers) {
|
|
12
|
-
const events = eventsData.filter(e => {
|
|
13
|
-
return !d.uniqueId.localeCompare(e.attributes.driverUniqueId, undefined, { sensitivity: 'base' })
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
if (events.length) {
|
|
17
|
-
driversIds.push(d.id)
|
|
18
|
-
}
|
|
9
|
+
const driverUniqueIdsToProcess = new Set(eventsData.map(e => e.attributes.driverUniqueId))
|
|
10
|
+
const driversToProcess = drivers.filter(d => driverUniqueIdsToProcess.has(d.uniqueId))
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
const deviceIdsToProcess = new Set(eventsData.map(e => e.deviceId))
|
|
13
|
+
const devicesToProcess = devices.filter(d => deviceIdsToProcess.has(d.id))
|
|
14
|
+
|
|
15
|
+
return { devices: devicesToProcess, drivers: driversToProcess }
|
|
23
16
|
}
|
|
24
17
|
|
|
25
18
|
async function reportByDriver (devices, traccar, from, to, userData, processor, allInOneData = { route: true, trips: true, stops: true, summary: false }) {
|