fleetmap-reports 1.0.450 → 1.0.453
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/lang/index.js +3 -0
- package/package.json +1 -1
- package/src/idle-report.js +1 -2
- package/src/index.test.js +16 -14
- package/src/util/odoo.js +7 -9
package/lang/index.js
CHANGED
package/package.json
CHANGED
package/src/idle-report.js
CHANGED
|
@@ -166,8 +166,7 @@ function processDevices (from, to, devices, routes, userData) {
|
|
|
166
166
|
const route = routes.filter(p => p.deviceId === d.id)
|
|
167
167
|
|
|
168
168
|
const idleEvents = getIdleEvents(route)
|
|
169
|
-
|
|
170
|
-
const filteredEvents = idleEvents.filter(e => userData.minimumIdleMinutes ? e.idleTime > userData.minimumIdleMinutes * 60 * 1000 : true)
|
|
169
|
+
const filteredEvents = idleEvents.filter(e => e.idleTime > (userData.minimumIdleMinutes ? userData.minimumIdleMinutes * 60 * 1000 : 0))
|
|
171
170
|
|
|
172
171
|
if (filteredEvents.length) {
|
|
173
172
|
filteredEvents.forEach(e => {
|
package/src/index.test.js
CHANGED
|
@@ -15,7 +15,6 @@ async function getSpeedingReport (report, userData) {
|
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line no-undef
|
|
17
17
|
describe('Test_Reports', function () {
|
|
18
|
-
this.timeout(500000)
|
|
19
18
|
// eslint-disable-next-line no-undef
|
|
20
19
|
it('Speeding by device', async () => {
|
|
21
20
|
const report = await getReports()
|
|
@@ -200,7 +199,7 @@ describe('Test_Reports', function () {
|
|
|
200
199
|
assert.equal(data.length, 1)
|
|
201
200
|
assert.equal(data.length, 1)
|
|
202
201
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
203
|
-
assert.equal(device.summary.distance,
|
|
202
|
+
assert.equal(device.summary.distance, 1183904.0299999565) // Total Kms
|
|
204
203
|
}, 30000)
|
|
205
204
|
// eslint-disable-next-line no-undef
|
|
206
205
|
it('KmsReport byDevice groupByDay', async () => {
|
|
@@ -214,7 +213,7 @@ describe('Test_Reports', function () {
|
|
|
214
213
|
assert.equal(data.length, 1)
|
|
215
214
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
216
215
|
assert.equal(device.days.length, 10) // Total Kms
|
|
217
|
-
assert.equal(device.days[5].kms,
|
|
216
|
+
assert.equal(device.days[5].kms, 23124.280000001192) // Total Kms
|
|
218
217
|
}, 30000)
|
|
219
218
|
// eslint-disable-next-line no-undef
|
|
220
219
|
it('Idle by device', async () => {
|
|
@@ -228,22 +227,25 @@ describe('Test_Reports', function () {
|
|
|
228
227
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
229
228
|
const totalIdleTime = device.idleEvents.reduce((a, b) => a + b.idleTime, 0)
|
|
230
229
|
assert.equal(device.idleEvents.length, 9) // Total Alerts
|
|
231
|
-
assert.equal(totalIdleTime,
|
|
230
|
+
assert.equal(totalIdleTime, 1592000) // Total Duration
|
|
232
231
|
}, 20000)
|
|
233
232
|
// eslint-disable-next-line no-undef
|
|
234
233
|
it('Idle by driver', async () => {
|
|
235
234
|
const report = await getReports()
|
|
236
235
|
const userData = await report.getUserData()
|
|
237
|
-
userData.minimumIdleMinutes =
|
|
236
|
+
userData.minimumIdleMinutes = 0
|
|
238
237
|
userData.byDriver = true
|
|
238
|
+
|
|
239
|
+
console.log(userData.drivers)
|
|
239
240
|
const data = await report.idleReport(new Date(2022, 0, 3, 0, 0, 0, 0),
|
|
240
241
|
new Date(2022, 0, 7, 23, 59, 59, 0),
|
|
241
242
|
userData)
|
|
242
243
|
assert.equal(data.length, 1)
|
|
243
244
|
const driver = data[0].drivers.find(d => d.driver.id === 14020)
|
|
245
|
+
|
|
244
246
|
const totalIdleTime = driver.idleEvents.reduce((a, b) => a + b.idleTime, 0)
|
|
245
|
-
assert.equal(driver.idleEvents.length,
|
|
246
|
-
assert.equal(totalIdleTime,
|
|
247
|
+
assert.equal(driver.idleEvents.length, 15) // Total Alerts
|
|
248
|
+
assert.equal(totalIdleTime, 16000) // Total Duration
|
|
247
249
|
}, 20000)
|
|
248
250
|
// eslint-disable-next-line no-undef
|
|
249
251
|
it('Activity by device', async () => {
|
|
@@ -256,7 +258,7 @@ describe('Test_Reports', function () {
|
|
|
256
258
|
assert.equal(data.length, 1)
|
|
257
259
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
258
260
|
assert.equal(device.summary[0].startOdometer, 122502742.59)
|
|
259
|
-
assert.equal(device.summary[0].distance,
|
|
261
|
+
assert.equal(device.summary[0].distance, 1404204.4299999028)
|
|
260
262
|
assert.equal(device.summary[0].startTime, '2022-01-01T13:35:47.000+0000')
|
|
261
263
|
assert.equal(device.summary[0].endTime, '2022-01-31T17:36:27.000+0000')
|
|
262
264
|
}, 40000)
|
|
@@ -284,8 +286,8 @@ describe('Test_Reports', function () {
|
|
|
284
286
|
assert.equal(data.length, 1)
|
|
285
287
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
286
288
|
assert.equal(device.summary[5].startOdometer, 122923290.95)
|
|
287
|
-
assert.equal(device.summary[5].distance,
|
|
288
|
-
assert.equal(device.summary[5].startTime, '2022-01-06T18:35:
|
|
289
|
+
assert.equal(device.summary[5].distance, 77021.6400000006)
|
|
290
|
+
assert.equal(device.summary[5].startTime, '2022-01-06T18:35:36.000+0000')
|
|
289
291
|
assert.equal(device.summary[5].endTime, '2022-01-06T19:54:27.000+0000')
|
|
290
292
|
}, 90000)
|
|
291
293
|
// eslint-disable-next-line no-undef
|
|
@@ -321,11 +323,11 @@ describe('Test_Reports', function () {
|
|
|
321
323
|
userData)
|
|
322
324
|
|
|
323
325
|
assert.equal(tripsReport.length, 1)
|
|
324
|
-
const device1 = tripsReport[0].devices.find(d => d.device.id ===
|
|
325
|
-
assert.equal(device1.trips.length,
|
|
326
|
-
assert.equal(device1.totalDistance,
|
|
326
|
+
const device1 = tripsReport[0].devices.find(d => d.device.id === 22327)
|
|
327
|
+
assert.equal(device1.trips.length, 14) // Total Trips
|
|
328
|
+
assert.equal(device1.totalDistance, 83553.13999999687) // Total Kms
|
|
327
329
|
|
|
328
|
-
const device2 = kmsReport[0].devices.find(d => d.device.id ===
|
|
330
|
+
const device2 = kmsReport[0].devices.find(d => d.device.id === 22327)
|
|
329
331
|
assert.equal(device2.summary.distance, device1.totalDistance) // Total Kms
|
|
330
332
|
}, 30000)
|
|
331
333
|
// eslint-disable-next-line no-undef
|
package/src/util/odoo.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
|
|
2
|
-
async function getOdooFuelServices
|
|
3
|
-
|
|
2
|
+
async function getOdooFuelServices(traccar, from, to) {
|
|
3
|
+
const url = `/odoo/reports/refuelingServices?startDate=${from.toDateString()}&endDate=${to.toDateString()}`
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
withCredentials: true
|
|
9
|
-
})
|
|
5
|
+
const {data} = await traccar.axios.get(url,{
|
|
6
|
+
jar: traccar.cookieJar,
|
|
7
|
+
withCredentials: true })
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
console.log(data)
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
return data
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
exports.getOdooFuelServices = getOdooFuelServices
|