fleetmap-reports 1.0.315 → 1.0.320

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.315",
3
+ "version": "1.0.320",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -25,7 +25,7 @@ async function createEventsReport(from, to, userData, traccar) {
25
25
  xpert: devices.filter(d => d.attributes.xpert).length > 0
26
26
  }
27
27
 
28
- const data = await getReportData(from, to, devices, userData.eventTypes)
28
+ const data = await getReportData(from, to, devices, userData.eventTypes, traccar)
29
29
 
30
30
  devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
31
31
 
@@ -45,7 +45,7 @@ async function createTripReportByGroup(from, to, userData, traccarInstance) {
45
45
 
46
46
  if (routes.length > 0) {
47
47
  console.log('Routes:' + routes.length)
48
- groupData.devices = processDevices(from, to, devices, routes)
48
+ groupData.devices = processDevices(from, to, devices, routes, userData)
49
49
 
50
50
  reportData.push(groupData)
51
51
  }
@@ -76,13 +76,13 @@ async function createTripReportByDevice(from, to, devices, userData, traccarInst
76
76
  console.log('Route:' + route.length)
77
77
 
78
78
  if (route.length > 0) {
79
- allData.devices = processDevices(from, to, devices, route)
79
+ allData.devices = processDevices(from, to, devices, route, userData)
80
80
  }
81
81
 
82
82
  return allData
83
83
  }
84
84
 
85
- function processDevices(from, to, devices, routes) {
85
+ function processDevices(from, to, devices, routes, userData) {
86
86
  const devicesResult = []
87
87
 
88
88
  devices.forEach(d => {
@@ -107,10 +107,12 @@ function processDevices(from, to, devices, routes) {
107
107
  }
108
108
  })
109
109
 
110
- if(idleEvents.length) {
110
+ const filteredEvents = idleEvents.filter(e => userData.minimumIdleMinutes ? e.idleTime > userData.minimumIdleMinutes*60*1000 : true)
111
+
112
+ if(filteredEvents.length) {
111
113
  const deviceData = {
112
114
  device: d,
113
- idleEvents: idleEvents
115
+ idleEvents: filteredEvents
114
116
  }
115
117
  devicesResult.push(deviceData)
116
118
  }
package/src/kms-report.js CHANGED
@@ -103,7 +103,7 @@ async function createKmsReportByGroup(from, to, userData, traccarInstance) {
103
103
  }
104
104
  }
105
105
 
106
- const withoutGroupData = await createKmsReportByDevice(from, to)
106
+ const withoutGroupData = await createKmsReportByDevice(from, to, userData, traccarInstance)
107
107
  reportData.push(withoutGroupData)
108
108
 
109
109
  return reportData
@@ -63,7 +63,7 @@ async function createSpeedingReportByGroup(from, to, userData, traccarInstance){
63
63
  const groupIds = userData.groups.map(g => g.id)
64
64
  const withoutGroupDevices = userData.devices.filter(d => !groupIds.includes(d.groupId))
65
65
 
66
- const withoutGroupData = await createSpeedingReportByDevice(from, to, withoutGroupDevices)
66
+ const withoutGroupData = await createSpeedingReportByDevice(from, to, withoutGroupDevices, userData, traccarInstance)
67
67
  reportData.push(withoutGroupData)
68
68
 
69
69
  return reportData