fleetmap-reports 1.0.502 → 1.0.503

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.502",
3
+ "version": "1.0.503",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
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(5000000)
19
18
  // eslint-disable-next-line no-undef
20
19
  it('Speeding by device', async () => {
21
20
  const report = await getReports()
@@ -37,7 +36,7 @@ describe('Test_Reports', function () {
37
36
  assert.equal(device.alerts.length, 13) // Total Alerts
38
37
  assert.equal(totalDistance, 46.64576895855739) // Total Kms
39
38
  assert.equal(totalEventTime, 1402000) // Total Duration
40
- }, 30000)
39
+ }, 20000)
41
40
  // eslint-disable-next-line no-undef
42
41
  it('Trip by device', async () => {
43
42
  const report = await getReports()
@@ -377,7 +376,7 @@ describe('Test_Reports', function () {
377
376
  assert.equal(device.days[0].spentFuel, 2)
378
377
  }, 30000)
379
378
  // eslint-disable-next-line no-undef
380
- /* it('FuelConsumption Odoo Report', async () => {
379
+ it('FuelConsumption Odoo Report', async () => {
381
380
  const report = await getReports()
382
381
  const userData = await report.getUserData()
383
382
  userData.withOdooServices = true
@@ -392,21 +391,6 @@ describe('Test_Reports', function () {
392
391
  assert.equal(device.days.length, 25)
393
392
  }, 30000)
394
393
  // eslint-disable-next-line no-undef
395
- it('FuelConsumption Odoo13 Report', async () => {
396
- const report = await getReports()
397
- const userData = await report.getUserData()
398
- userData.withOdooServices = true
399
- userData.devices = userData.devices.filter(d => d.id === 22326)
400
- const data = await report.fuelConsumptionReport(
401
- new Date(Date.UTC(2022, 9, 1, 0, 0, 0, 0)),
402
- new Date(Date.UTC(2022, 9, 31, 23, 59, 59, 0)),
403
- userData)
404
-
405
- assert.equal(data.length, 1)
406
- const device = data[0].devices.find(d => d.device.id === 22326)
407
- assert.equal(device.days.length, 25)
408
- }, 30000) */
409
- // eslint-disable-next-line no-undef
410
394
  it('Zone Report', async () => {
411
395
  const report = await getReports()
412
396
  const userData = await report.getUserData()
@@ -80,21 +80,23 @@ async function createSpeedingReportByDevice (from, to, userData, traccarInstance
80
80
  xpert: devices.filter(d => d && d.attributes && d.attributes.xpert).length > 0
81
81
  }
82
82
 
83
- const sliced = automaticReports.sliceArray(devices, 10)
83
+ const _sliced = automaticReports.sliceArray(automaticReports.sliceArray(devices, 10), 150)
84
84
 
85
85
  let deviceCount = 0
86
- await Promise.all(sliced.map(async slice => {
87
- const { routes, events } = await getEvents(traccarInstance, from, to, slice, userData, deviceCount, devices.length, slice.length)
88
- if (events.length > 0) {
89
- const devicesProcessed = await processDevices(from, to, slice, events, routes, userData)
90
- allData.devices.push(...devicesProcessed)
91
- }
92
- deviceCount = deviceCount + slice.length
93
- if (processServerSide()) {
94
- console.log('LOADING_MESSAGE:' + slice[0].name)
95
- console.log(`PROGRESS_PERC:${deviceCount / devices.length * 100}`)
96
- }
97
- }))
86
+ for (const sliced of _sliced) {
87
+ await Promise.all(sliced.map(async slice => {
88
+ const { routes, events } = await getEvents(traccarInstance, from, to, slice, userData, deviceCount, devices.length, slice.length)
89
+ if (events.length > 0) {
90
+ const devicesProcessed = await processDevices(from, to, slice, events, routes, userData)
91
+ allData.devices.push(...devicesProcessed)
92
+ }
93
+ deviceCount = deviceCount + slice.length
94
+ if (processServerSide()) {
95
+ console.log('LOADING_MESSAGE:' + slice[0].name)
96
+ console.log(`PROGRESS_PERC:${deviceCount / devices.length * 100}`)
97
+ }
98
+ }))
99
+ }
98
100
 
99
101
  return allData
100
102
  }
package/src/util/odoo.js CHANGED
@@ -1,20 +1,14 @@
1
1
 
2
- async function getOdooFuelServices (traccar, from, to) {
3
- const url = `/odoo/reports/refuelingServices?startDate=${from.toDateString()}&endDate=${to.toDateString()}`
2
+ async function getOdooFuelServices(traccar, from, to) {
3
+ const url = `/odoo/reports/refuelingServices?startDate=${from.toDateString()}&endDate=${to.toDateString()}`
4
4
 
5
- console.log('LOADING_MESSAGE:' + url)
6
- console.log(await traccar.axios.get(url, {
7
- jar: traccar.cookieJar,
8
- withCredentials: true
9
- }))
10
- const { data } = await traccar.axios.get(url, {
11
- jar: traccar.cookieJar,
12
- withCredentials: true
13
- })
5
+ const {data} = await traccar.axios.get(url,{
6
+ jar: traccar.cookieJar,
7
+ withCredentials: true })
14
8
 
15
- console.log(data)
9
+ console.log(data)
16
10
 
17
- return data
11
+ return data
18
12
  }
19
13
 
20
14
  exports.getOdooFuelServices = getOdooFuelServices
@@ -91,7 +91,6 @@ async function getAllInOne (
91
91
  const requests = []
92
92
  for (const _chunk of automaticReports.sliceArray(chunk, devicesPerRequest)) {
93
93
  const u = url + '&' + _chunk.map(d => `deviceId=${d.id}`).join('&')
94
- console.log(u)
95
94
  requests.push(
96
95
  traccar.axios.get(u, {
97
96
  jar: traccar.cookieJar,