fleetmap-reports 2.0.30 → 2.0.32

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": "2.0.30",
3
+ "version": "2.0.32",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/kms-report.js CHANGED
@@ -117,7 +117,7 @@ async function createKmsReportByDriver (from, to, userData, traccarInstance) {
117
117
  report.drivers = drivers
118
118
  })
119
119
  } else {
120
- const results = await reportByDriver(userData.devices, traccarInstance, from, to, userData, processDrivers)
120
+ const results = await reportByDriver(userData.devices, traccarInstance, from, to, userData, processDrivers, { route: true, trips: true, stops: false, summary: false })
121
121
 
122
122
  results.drivers.forEach(result => {
123
123
  const driver = report.drivers.find(d => d.driver.id === result.driver.id)
@@ -177,10 +177,8 @@ async function createKmsReportByGroup (from, to, userData, traccarInstance) {
177
177
 
178
178
  async function processDrivers (from, to, userData, data) {
179
179
  const driversResult = []
180
- const driversOnRoute = data.route ? new Set(data.route.map(p => p.attributes.driverUniqueId)) : new Set([])
181
- const driverToProcess = userData.drivers.filter(d => driversOnRoute.has(d.uniqueId))
182
180
 
183
- for (const d of driverToProcess) {
181
+ for (const d of userData.drivers) {
184
182
  const { trips } = await getDriverData(d, data, userData)
185
183
 
186
184
  if (trips.length > 0) {
@@ -53,11 +53,11 @@ describe('Kms_Reports', function () {
53
53
  assert.equal(device.days[29].kms, 136174.93281451002) // Total Kms
54
54
  }, 30000)
55
55
  it('KmsReport by driver', async () => {
56
- const reports = await getReports()
56
+ const reports = await getReports(process.env.USER_CTM_MOVIFLOTTE, process.env.PASS_CTM_MOVIFLOTTE)
57
57
  const userData = await reports.getUserData()
58
58
  userData.byDriver = true
59
59
  console.log(userData.drivers)
60
- const data = await reports.kmsReport(new Date(2024, 0, 24, 0, 0, 0), new Date(2024, 0, 24, 23, 59, 59),
60
+ const data = await reports.kmsReport(new Date(2024, 0, 1, 0, 0, 0), new Date(2024, 0, 31, 23, 59, 59),
61
61
  userData)
62
62
  assert.equal(data.length, 1)
63
63
  }, 3000000)
@@ -22,14 +22,14 @@ async function devicesByDriver (traccarInstance, from, to, drivers, devices) {
22
22
  return { devices: devices.filter(d => deviceIds.includes(d.id)), drivers: drivers.filter(d => driversIds.includes(d.id)) }
23
23
  }
24
24
 
25
- async function reportByDriver (devices, traccar, from, to, userData, processor) {
25
+ async function reportByDriver (devices, traccar, from, to, userData, processor, allInOneData = { route: true, trips: true, stops: true, summary: false }) {
26
26
  const report = { drivers: [] }
27
27
 
28
28
  const sliced = automaticReports.sliceArray(devices, 5)
29
29
 
30
30
  let deviceCount = 0
31
31
  for (const slice of sliced) {
32
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, true, false, deviceCount, devices.length)
32
+ const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, allInOneData.route, allInOneData.trips, allInOneData.stops, allInOneData.summary, deviceCount, devices.length)
33
33
  const results = await processor(from, to, userData, { trips: allInOne.trips, route: allInOne.route, stops: allInOne.stops })
34
34
  report.drivers.push(...results)
35
35
  deviceCount = deviceCount + slice.length
package/src/util/utils.js CHANGED
@@ -127,7 +127,7 @@ function getDates (startDate, endDate, timezone) {
127
127
  }
128
128
 
129
129
  function getImage (url) {
130
- return require('axios').get(url, { responseType: 'arraybuffer' }).then(d => d.data)
130
+ return require('axios').default.get(url, { responseType: 'arraybuffer' }).then(d => d.data)
131
131
  }
132
132
 
133
133
  async function getImageBase64 (url) {