fleetmap-reports 1.0.774 → 1.0.776

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.774",
3
+ "version": "1.0.776",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -124,20 +124,20 @@ function getDeviceData (allInOne, d) {
124
124
  economicDistance
125
125
  }
126
126
  } else {
127
- const deviceSummary = allInOne.summary.filter(t => t.deviceId === d.id)
127
+ const deviceSummary = allInOne.summary.filter(t => t.deviceId === d.id)[0]
128
128
 
129
129
  const drivingTime = deviceTrips.reduce((a, b) => a + b.duration, 0)
130
130
  const drivingConsumption = deviceTrips.reduce((a, b) => a + b.spentFuel, 0)
131
- const drivingDistance = deviceSummary[0].distance / 1000
132
- const idleTime = deviceSummary[0].engineHours > drivingTime ? deviceSummary[0].engineHours - drivingTime : 0
133
- const idleConsumption = deviceSummary[0].spentFuel > drivingConsumption ? deviceSummary[0].spentFuel - drivingConsumption : 0
131
+ const drivingDistance = deviceSummary ? deviceSummary.distance / 1000 : 0
132
+ const idleTime = deviceSummary && deviceSummary.engineHours > drivingTime ? deviceSummary.engineHours - drivingTime : 0
133
+ const idleConsumption = deviceSummary && deviceSummary.spentFuel > drivingConsumption ? deviceSummary.spentFuel - drivingConsumption : 0
134
134
 
135
135
  const hardBreaking = deviceRoute.filter(p => p.attributes.io253 === 2).length
136
136
  const hardAcceleration = deviceRoute.filter(p => p.attributes.io253 === 1).length
137
137
 
138
138
  return {
139
- drivingTime,
140
- idleTime,
139
+ drivingTime: drivingTime / 1000,
140
+ idleTime: idleTime / 1000,
141
141
  cruiseControlTime: 0,
142
142
  economicTime: 0,
143
143
  highEngineRPM: 0,
@@ -1,10 +1,11 @@
1
1
  const { getReports } = require('./index')
2
2
  const { createPerformanceReport } = require('../partnerReports/performance-report')
3
3
  const assert = require('assert')
4
+ const { convertMS } = require('../util/utils')
4
5
  // eslint-disable-next-line no-undef
5
6
  describe('performance', function () {
6
7
  // eslint-disable-next-line no-undef
7
- it('performance report', async () => {
8
+ it('performance report teltonika', async () => {
8
9
  const report = await getReports()
9
10
  const userData = await report.getUserData()
10
11
  userData.devices = userData.devices.filter(d => d.id === 22326)
@@ -13,11 +14,13 @@ describe('performance', function () {
13
14
  new Date(Date.UTC(2023, 5, 20, 23, 59, 59, 0)),
14
15
  userData,
15
16
  report.traccar)
16
- console.log(data)
17
- }, 5000000)
17
+ assert.equal(data[0].consumption, 21.8)
18
+ assert.equal(data[0].distance, 381.29861000000005)
19
+ assert.equal(convertMS(data[1].time * 1000, false), '10:30')
20
+ }, 8000000)
18
21
 
19
22
  // eslint-disable-next-line no-undef
20
- it('performance report 2', async () => {
23
+ it('performance report inofleet', async () => {
21
24
  const report = await getReports()
22
25
  const userData = await report.getUserData()
23
26
  userData.devices = userData.devices.filter(d => d.id === 69114)