fleetmap-reports 1.0.794 → 1.0.795
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 +1 -1
- package/src/activity-report.js +13 -15
- package/src/tests/activity.test.js +3 -3
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -188,21 +188,19 @@ function processDevices (from, to, devices, data, userData) {
|
|
|
188
188
|
})
|
|
189
189
|
}
|
|
190
190
|
} else {
|
|
191
|
-
const summaryCurrentDay =
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
summary.push(summaryCurrentDay)
|
|
205
|
-
}
|
|
191
|
+
const summaryCurrentDay = { date, deviceId: d.id }
|
|
192
|
+
summaryCurrentDay.engineHours = tripsByDay.reduce((a, b) => a + b.duration, 0)
|
|
193
|
+
summaryCurrentDay.distance = distance
|
|
194
|
+
summaryCurrentDay.averageSpeed = distance > 0 ? ((trips.reduce((a, b) => a + (b.averageSpeed * b.distance), 0)) / distance) : 0
|
|
195
|
+
summaryCurrentDay.maxSpeed = tripsByDay.reduce((a, b) => { return a > b.maxSpeed ? a : b.maxSpeed }, 0)
|
|
196
|
+
summaryCurrentDay.convertedSpentFuel = calculateConsumption(d, { route: deviceRoute })
|
|
197
|
+
summaryCurrentDay.startTime = tripsByDay.length && tripsByDay[0].startTime
|
|
198
|
+
summaryCurrentDay.startAddress = tripsByDay.length && tripsByDay[0].startAddress
|
|
199
|
+
summaryCurrentDay.endTime = tripsByDay.length && tripsByDay[tripsByDay.length - 1].endTime
|
|
200
|
+
summaryCurrentDay.endAddress = tripsByDay.length && tripsByDay[tripsByDay.length - 1].endAddress
|
|
201
|
+
summaryCurrentDay.startOdometer = trips.length ? trips[0].startOdometer : 0
|
|
202
|
+
summaryCurrentDay.endOdometer = trips.length ? trips[trips.length - 1].endOdometer : 0
|
|
203
|
+
summary.push(summaryCurrentDay)
|
|
206
204
|
}
|
|
207
205
|
}
|
|
208
206
|
} else {
|
|
@@ -7,9 +7,9 @@ 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
15
|
const device = data[0].devices.find(d => d.device.id === 22326)
|