fleetmap-reports 1.0.643 → 1.0.644

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.643",
3
+ "version": "1.0.644",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -34,6 +34,7 @@ async function createActivityReport (from, to, userData, traccarInstance) {
34
34
  let unauthorizedStops = 0
35
35
  let authorizedStops = 0
36
36
  let otherStops = 0
37
+ let authorizedStopsTime = 0
37
38
 
38
39
  stops.forEach(s => {
39
40
  const unauthorized = unauthorizedGeofences.find(g => insideGeofence({ latitude: s.latitude, longitude: s.longitude }, g))
@@ -45,6 +46,7 @@ async function createActivityReport (from, to, userData, traccarInstance) {
45
46
 
46
47
  if (authorized) {
47
48
  authorizedStops = authorizedStops + 1
49
+ authorizedStopsTime = authorizedStopsTime + (s.duration > s.engineHours ? (s.duration - s.engineHours) : 0)
48
50
  } else {
49
51
  otherStops = otherStops + 1
50
52
  }
@@ -102,7 +104,7 @@ async function createActivityReport (from, to, userData, traccarInstance) {
102
104
  otherStops,
103
105
  authorizedStops,
104
106
  unauthorizedStops,
105
- authorizedStopsTime: unauthorizedStops.reduce((a, b) => a + (b.duration > b.engineHours ? (b.duration - b.engineHours) : 0), 0),
107
+ authorizedStopsTime,
106
108
  averageSpeed: totalDistance > 0 ? ((trips.reduce((a, b) => a + (b.averageSpeed * b.distance), 0)) / totalDistance) : 0,
107
109
  maxSpeed: trips.reduce((a, b) => {
108
110
  return a > b.maxSpeed ? a : b.maxSpeed