fleetmap-reports 1.0.639 → 1.0.640

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.639",
3
+ "version": "1.0.640",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -7,23 +7,25 @@ function calculateLastStopTime (stopTime, to, time) {
7
7
  }
8
8
 
9
9
  function calculateFirstStopTime (stopTime, from, time) {
10
- return stopTime + (new Date(time).getTime(), from.getTime())
10
+ return stopTime + (new Date(time).getTime() - from.getTime())
11
11
  }
12
12
 
13
13
  async function createActivityReport (from, to, userData, traccarInstance) {
14
- const notAuthGroup = userData.groups.find(g => g.name === 'Zones Non Autorisées')
15
- const authGroup = userData.groups.find(g => g.name === 'Zones Autorisées')
14
+ const notAuthGroup = userData.groups.find(g => g.id === process.env.AFRIQUIA_NOT_AUTH_GROUP_ID)
15
+ const authGroup = userData.groups.find(g => g.id === process.env.AFRIQUIA_AUTH_GROUP_ID)
16
16
 
17
17
  const unauthorizedGeofences = []
18
18
  const authorizedGeofences = []
19
19
  if (notAuthGroup) {
20
20
  const geofenceIds = (await traccarInstance.geofences.geofencesGet(undefined, undefined, undefined, notAuthGroup.id, undefined, undefined).then(r => r.data)).map(g => g.id)
21
21
  unauthorizedGeofences.push(...(userData.geofences.filter(g => geofenceIds.includes(g.id))))
22
+ console.log('unauthorizedGeofences', unauthorizedGeofences)
22
23
  }
23
24
 
24
25
  if (authGroup) {
25
26
  const geofenceIds = (await traccarInstance.geofences.geofencesGet(undefined, undefined, undefined, authGroup.id, undefined, undefined).then(r => r.data)).map(g => g.id)
26
27
  authorizedGeofences.push(...(userData.geofences.filter(g => geofenceIds.includes(g.id))))
28
+ console.log('authorizedGeofences', unauthorizedGeofences)
27
29
  }
28
30
 
29
31
  const allInOne = await traccar.getAllInOne(traccarInstance, from, to, userData.devices, true, true, true, false)