fleetmap-reports 1.0.953 → 1.0.954

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.953",
3
+ "version": "1.0.954",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -59,5 +59,6 @@ describe('zones', function () {
59
59
  const first = result[0].devices[0]
60
60
  console.log(first)
61
61
  assert.equal(first.days[0].distanceOut, 0)
62
+ assert.equal(first.days[2].distanceOut, 0)
62
63
  }, 4000000)
63
64
  })
@@ -62,7 +62,7 @@ async function createTripReportByDevice (from, to, userData, traccar) {
62
62
 
63
63
  if (tripsData.length > 0) {
64
64
  trips.checkTripsKms(traccar, from, to, slice, { trips: tripsData, route: routeData })
65
- allData.devices.push(...processDevices(from, to, slice, {
65
+ allData.devices.push(...await processDevices(from, to, slice, {
66
66
  trips: tripsData,
67
67
  stops: stopsData,
68
68
  route: routeData
@@ -99,7 +99,7 @@ async function createTripReportByGroup (from, to, userData, traccar) {
99
99
 
100
100
  if (tripsData.length > 0) {
101
101
  console.log('Trips:' + tripsData.length)
102
- groupData.devices = processDevices(from, to, devices, { trips: tripsData, stops: stopsData, route: routeData }, userData)
102
+ groupData.devices = await processDevices(from, to, devices, { trips: tripsData, stops: stopsData, route: routeData }, userData)
103
103
 
104
104
  reportData.push(groupData)
105
105
  }
@@ -145,10 +145,10 @@ async function createTripReportByDriver (from, to, userData, traccar) {
145
145
  return report
146
146
  }
147
147
 
148
- function processDevices (from, to, devices, data, userData, traccar) {
148
+ async function processDevices (from, to, devices, data, userData, traccar) {
149
149
  const devicesResult = []
150
150
 
151
- devices.forEach(d => {
151
+ for (const d of devices) {
152
152
  const deviceRoute = data.route.filter(t => t.deviceId === d.id)
153
153
  const deviceTrips = data.trips.filter(t => t.deviceId === d.id)
154
154
 
@@ -157,7 +157,17 @@ function processDevices (from, to, devices, data, userData, traccar) {
157
157
  deviceTrips.push(uncompletedTrip)
158
158
  }
159
159
 
160
- const trips = deviceTrips.filter(t => userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData) || isPartialInsideTimetable(t, userData, deviceRoute))
160
+ const trips = []
161
+
162
+ for (const t of deviceTrips) {
163
+ if (userData.allWeek ||
164
+ !userData.weekDays ||
165
+ isInsideTimetable(t, userData) ||
166
+ await isPartialInsideTimetable(t, userData, deviceRoute)) {
167
+ trips.push(t)
168
+ }
169
+ }
170
+
161
171
  const stops = data.stops.filter(s => s.deviceId === d.id)
162
172
 
163
173
  trips.forEach(trip => {
@@ -224,7 +234,7 @@ function processDevices (from, to, devices, data, userData, traccar) {
224
234
 
225
235
  devicesResult.push(deviceData)
226
236
  }
227
- })
237
+ }
228
238
 
229
239
  return devicesResult
230
240
  }