fleetmap-reports 1.0.343 → 1.0.344
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 +19 -10
- package/src/index.test.js +6 -2
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -172,19 +172,21 @@ function processDevices(from, to, devices, data, userData) {
|
|
|
172
172
|
return a > b.maxSpeed ? a : b.maxSpeed
|
|
173
173
|
}, 0),
|
|
174
174
|
endOdometer: 0,
|
|
175
|
-
startOdometer: 0
|
|
175
|
+
startOdometer: 0,
|
|
176
|
+
startTime: tripsByDay.length && tripsByDay[0].startTime,
|
|
177
|
+
endTime: tripsByDay.length && tripsByDay[tripsByDay.length-1].endTime
|
|
176
178
|
})
|
|
177
179
|
} else {
|
|
178
|
-
const summaryCurrentDay = data.summaries.
|
|
180
|
+
const summaryCurrentDay = data.summaries.find(s => {
|
|
179
181
|
return s.deviceId === d.id && s.date.getTime() === date.getTime()})
|
|
180
182
|
|
|
181
|
-
if (summaryCurrentDay
|
|
182
|
-
summaryCurrentDay.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
if (summaryCurrentDay) {
|
|
184
|
+
summaryCurrentDay.distance = distance
|
|
185
|
+
summaryCurrentDay.convertedSpentFuel = automaticReports.calculateSpentFuel(summaryCurrentDay.spentFuel, d)
|
|
186
|
+
summaryCurrentDay.startTime = tripsByDay.length && tripsByDay[0].startTime
|
|
187
|
+
summaryCurrentDay.endTime = tripsByDay.length && tripsByDay[tripsByDay.length-1].endTime
|
|
186
188
|
|
|
187
|
-
summary.push(
|
|
189
|
+
summary.push(summaryCurrentDay)
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
}
|
|
@@ -193,8 +195,11 @@ function processDevices(from, to, devices, data, userData) {
|
|
|
193
195
|
|
|
194
196
|
if (summary.length) {
|
|
195
197
|
summary.forEach(s => {
|
|
196
|
-
|
|
198
|
+
const deviceTrips = data.trips.filter(t => t.deviceId === d.id)
|
|
199
|
+
s.distance = deviceTrips.reduce((a, b) => a + b.distance, 0)
|
|
197
200
|
s.convertedSpentFuel = automaticReports.calculateSpentFuel(s.spentFuel, d)
|
|
201
|
+
s.startTime = deviceTrips.length && deviceTrips[0].startTime
|
|
202
|
+
s.endTime = deviceTrips.length && deviceTrips[deviceTrips.length-1].endTime
|
|
198
203
|
})
|
|
199
204
|
}
|
|
200
205
|
}
|
|
@@ -234,7 +239,9 @@ function processDrivers(from, to, drivers, data, userData) {
|
|
|
234
239
|
distance: tripsByDay.filter(t => t.distance > 0).reduce((a, b) => a + b.distance, 0),
|
|
235
240
|
engineHours: tripsByDay.reduce((a, b) => a + b.duration, 0),
|
|
236
241
|
maxSpeed: tripsByDay.reduce((a, b) => Math.max(a, b.maxSpeed), 0),
|
|
237
|
-
averageSpeed: tripsByDay.length
|
|
242
|
+
averageSpeed: tripsByDay.length ? Math.round(tripsByDay.reduce((a, b) => a + b.averageSpeed, 0) / tripsByDay.length) : 0,
|
|
243
|
+
startTime: tripsByDay.length && tripsByDay[0].startTime,
|
|
244
|
+
endTime: tripsByDay.length && tripsByDay[tripsByDay.length-1].endTime
|
|
238
245
|
})
|
|
239
246
|
}
|
|
240
247
|
} else {
|
|
@@ -243,6 +250,8 @@ function processDrivers(from, to, drivers, data, userData) {
|
|
|
243
250
|
engineHours: trips.reduce((a, b) => a + b.duration, 0),
|
|
244
251
|
maxSpeed: trips.reduce((a, b) => Math.max(a, b.maxSpeed), 0),
|
|
245
252
|
averageSpeed: Math.round(trips.reduce((a, b) => a + b.averageSpeed, 0) / trips.length),
|
|
253
|
+
startTime: trips.length && trips[0].startTime,
|
|
254
|
+
endTime: trips.length && trips[trips.length-1].endTime
|
|
246
255
|
})
|
|
247
256
|
}
|
|
248
257
|
driversResult.push(driverData)
|
package/src/index.test.js
CHANGED
|
@@ -125,7 +125,7 @@ describe('Test_Reports', function() {
|
|
|
125
125
|
assert.equal(data.length, 1)
|
|
126
126
|
const device = data[0].devices.find(d => d.device.id===22326)
|
|
127
127
|
assert.equal(device.summary.distance, 1193284.3100000024) // Total Kms
|
|
128
|
-
},
|
|
128
|
+
},30000)
|
|
129
129
|
it('KmsReport byDevice groupByDay', async () => {
|
|
130
130
|
const reports = await getReports()
|
|
131
131
|
const userData = await reports.getUserData()
|
|
@@ -137,7 +137,7 @@ describe('Test_Reports', function() {
|
|
|
137
137
|
const device = data[0].devices.find(d => d.device.id===22326)
|
|
138
138
|
assert.equal(device.days.length, 10) // Total Kms
|
|
139
139
|
assert.equal(device.days[5].kms, 23183.010000005364) // Total Kms
|
|
140
|
-
},
|
|
140
|
+
},90000)
|
|
141
141
|
it('Idle by device', async () => {
|
|
142
142
|
const report = await getReports()
|
|
143
143
|
const userData = await report.getUserData()
|
|
@@ -162,6 +162,8 @@ describe('Test_Reports', function() {
|
|
|
162
162
|
const device = data[0].devices.find(d => d.device.id===22326)
|
|
163
163
|
assert.equal(device.summary[0].startOdometer, 122502742.59)
|
|
164
164
|
assert.equal(device.summary[0].distance, 1386519.1300000101)
|
|
165
|
+
assert.equal(device.summary[0].startTime, '2022-01-01T13:35:47.000+0000')
|
|
166
|
+
assert.equal(device.summary[0].endTime, '2022-01-30T13:48:18.000+0000')
|
|
165
167
|
}, 20000)
|
|
166
168
|
it('Activity byDevice groupByDay', async () => {
|
|
167
169
|
const report = await getReports()
|
|
@@ -174,6 +176,8 @@ describe('Test_Reports', function() {
|
|
|
174
176
|
const device = data[0].devices.find(d => d.device.id===22326)
|
|
175
177
|
assert.equal(device.summary[5].startOdometer, 122923290.95)
|
|
176
178
|
assert.equal(device.summary[5].distance, 77020.37999999523)
|
|
179
|
+
assert.equal(device.summary[5].startTime, '2022-01-06T18:35:04.000+0000')
|
|
180
|
+
assert.equal(device.summary[5].endTime, '2022-01-06T19:54:27.000+0000')
|
|
177
181
|
}, 60000)
|
|
178
182
|
it('test allinone', async() => {
|
|
179
183
|
console.log('Start')
|