fleetmap-reports 1.0.820 → 1.0.821
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
|
@@ -7,10 +7,6 @@ function calculateLastStopTime (stopTime, to, time) {
|
|
|
7
7
|
return stopTime + (to.getTime() - new Date(time).getTime())
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function calculateFirstStopTime (stopTime, from, time) {
|
|
11
|
-
return stopTime + (new Date(time).getTime() - from.getTime())
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
async function createActivityReport (from, to, userData, traccarInstance) {
|
|
15
11
|
const unauthorizedGeofences = []
|
|
16
12
|
const authorizedGeofences = []
|
|
@@ -7,14 +7,11 @@ describe('activity report', function () {
|
|
|
7
7
|
it('Activity by device', async () => {
|
|
8
8
|
const report = await getReports()
|
|
9
9
|
const userData = await report.getUserData()
|
|
10
|
-
|
|
11
|
-
const data = await report.activityReport(new Date(
|
|
12
|
-
new Date(
|
|
10
|
+
userData.groupByDay = true
|
|
11
|
+
const data = await report.activityReport(new Date(2023, 0, 1, 0, 0, 0, 0),
|
|
12
|
+
new Date(2023, 0, 31, 23, 59, 59, 0),
|
|
13
13
|
userData)
|
|
14
14
|
assert.equal(data.length, 1)
|
|
15
|
-
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
16
|
-
assert.equal(device.summary[0].startOdometer, 0)
|
|
17
|
-
assert.equal(device.summary[0].distance, 0)
|
|
18
15
|
assert.equal(device.summary[0].startTime, 0)
|
|
19
16
|
assert.equal(device.summary[0].endTime, 0)
|
|
20
17
|
}, 80000)
|
|
@@ -72,4 +69,14 @@ describe('activity report', function () {
|
|
|
72
69
|
console.log(device)
|
|
73
70
|
assert.equal(device.summary.reduce((a, b) => a + b.convertedSpentFuel, 0), 168.79999999999995)
|
|
74
71
|
}, 800000)
|
|
72
|
+
it('Activity test performance', async () => {
|
|
73
|
+
const report = await getReports('q.trans', 'quality1214')
|
|
74
|
+
const userData = await report.getUserData()
|
|
75
|
+
console.log(userData)
|
|
76
|
+
userData.groupByDay = true
|
|
77
|
+
const data = await report.activityReport(new Date(2023, 7, 1, 0, 0, 0, 0),
|
|
78
|
+
new Date(2023, 31, 5, 23, 59, 59, 0),
|
|
79
|
+
userData)
|
|
80
|
+
assert.equal(data.length, 1)
|
|
81
|
+
}, 8000000)
|
|
75
82
|
})
|
package/src/util/trips.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { coordsDistance, convertFromUTC, weekDaySelected, convertFromLocal, isClientSide } = require('./utils')
|
|
1
|
+
const { coordsDistance, convertFromUTC, weekDaySelected, convertFromLocal, isClientSide, calculateDistance } = require('./utils')
|
|
2
2
|
const { isInside } = require('./timetable')
|
|
3
3
|
|
|
4
4
|
const minDistance = 0
|
|
@@ -120,7 +120,7 @@ function calculateTrip (device, route) {
|
|
|
120
120
|
return {
|
|
121
121
|
deviceId: device.id,
|
|
122
122
|
deviceName: device.name,
|
|
123
|
-
distance: route
|
|
123
|
+
distance: calculateDistance(route) * 1000,
|
|
124
124
|
averageSpeed: Math.round((route.map(p => p.speed).reduce((a, b) => a + b, 0)) / route.length),
|
|
125
125
|
maxSpeed: route.map(p => p.speed).reduce(function (a, b) { return Math.max(a, b) }),
|
|
126
126
|
spentFuel: 0,
|