fleetmap-reports 1.0.420 → 1.0.421

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.420",
3
+ "version": "1.0.421",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.test.js CHANGED
@@ -52,6 +52,21 @@ describe('Test_Reports', function () {
52
52
  assert.equal(device.trips[1].endPOIName, undefined)
53
53
  assert.equal(device.totalDistance, 339204.53999999166) // Total Kms
54
54
  }, 20000)
55
+ it('Trip without addresses', async () => {
56
+ const report = await getReports()
57
+ const userData = await report.getUserData()
58
+
59
+ const data = await report.tripReport(new Date(2022, 4, 27, 0, 0, 0, 0),
60
+ new Date(2022, 4, 27, 23, 59, 59, 0),
61
+ userData)
62
+
63
+ assert.equal(data.length, 1)
64
+ const device = data[0].devices.find(d => d.device.id === 25808)
65
+ assert.equal(device.trips.length, 11) // Total Trips
66
+ console.log(device.trips[0])
67
+ assert.equal(device.trips[0].endAddress, 'Rua Cláudio Manoel 184-314;Vera Cruz;Vera Cruz;96880-000;BR\n')
68
+ assert.equal(device.trips[1].endPOIName, undefined)
69
+ }, 20000)
55
70
  // eslint-disable-next-line no-undef
56
71
  it('Trip 2 by device', async () => {
57
72
  const report = await getReports()
@@ -10,6 +10,7 @@ const trips = require('./util/trips')
10
10
  const { isInsideTimetable, addNearestPOIs, isPartialInsideTimetable, calculateTrip, getTripIdleTime } = require('./util/trips')
11
11
  const { devicesToProcess } = require('./util/device')
12
12
  const { getIdleEvents } = require('./util/route')
13
+ const axios = require('axios')
13
14
 
14
15
  const fileName = 'TripReport'
15
16
 
@@ -157,6 +158,9 @@ function processDevices (from, to, devices, data, userData) {
157
158
  trip.stopDuration = 0
158
159
  trip.stopEngineHours = 0
159
160
  }
161
+ if (trip.endAddress === null) {
162
+ axios.get(`https://geocoding.inosat.me/q?${trip.endLat},${trip.endLon}`).then(r => { trip.endAddress = r.data })
163
+ }
160
164
  })
161
165
 
162
166
  if (trips.length > 0) {