fleetmap-reports 1.0.700 → 1.0.701

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.700",
3
+ "version": "1.0.701",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,5 +1,8 @@
1
1
  const { getReports } = require('./index')
2
+ const assert = require('assert')
3
+ // eslint-disable-next-line no-undef
2
4
  describe('zones', function () {
5
+ // eslint-disable-next-line no-undef
3
6
  it('works with ellca', async () => {
4
7
  const report = await getReports()
5
8
  const userData = await report.getUserData()
@@ -16,16 +19,19 @@ describe('zones', function () {
16
19
  console.log('result', result)
17
20
  }, 4000000)
18
21
 
19
- it('works with afriquia', async () => {
20
- const report = await getReports('moviflotte@gmail.com', 'moviflotte@gmail.com')
22
+ // eslint-disable-next-line no-undef
23
+ it('works with casais', async () => {
24
+ const report = await getReports('mario.andre.moreira@casais.gi', 'Casais.23')
21
25
  const userData = await report.getUserData()
22
- console.log(userData.devices.length)
23
- console.log(userData.devices.map(d => d.id))
24
- console.log(userData.geofences)
26
+ userData.devices = userData.devices.filter(d => d.name === 'G-1101-E Clio')
27
+ userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ')
25
28
  const result = await report.zoneReport(
26
- new Date(Date.UTC(2023, 5, 11, 0, 0, 0, 0)),
27
- new Date(Date.UTC(2023, 5, 11, 23, 59, 59, 0)),
29
+ new Date(Date.UTC(2023, 0, 1, 0, 0, 0, 0)),
30
+ new Date(Date.UTC(2023, 0, 31, 23, 59, 59, 0)),
28
31
  userData)
29
- console.log('result', result)
32
+ const first = result[0].devices[0].geofences[0]
33
+ console.log(first)
34
+ assert.equal(first.inTime.fixTime, '2023-01-03T21:23:24.000+0000')
35
+ assert.equal(first.outTime.fixTime, '2023-01-07T12:22:53.000+0000')
30
36
  }, 4000000)
31
37
  })
package/src/util/utils.js CHANGED
@@ -245,4 +245,4 @@ exports.calculateDistance = (positions) => {
245
245
  }, 0) || 0
246
246
  }
247
247
 
248
- exports.sortPositions = (a, b) => new Date(a).getTime() - new Date(b).getTime()
248
+ exports.sortPositions = (a, b) => new Date(a.fixTime).getTime() - new Date(b.fixTime).getTime()
@@ -325,7 +325,7 @@ function getInAndOutEvents (devices, route, userData) {
325
325
  if (!checkGeofenceIn(p, g)) {
326
326
  deviceEvents.push(createEvent('geofenceExit', d.id, p, g))
327
327
  } else {
328
- previous.inside[id] = true
328
+ p.inside[id] = true
329
329
  }
330
330
  } else {
331
331
  if (checkGeofenceIn(p, g)) {