fleetmap-reports 1.0.925 → 1.0.928

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.925",
3
+ "version": "1.0.928",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/kms-report.js CHANGED
@@ -44,7 +44,7 @@ async function createKmsReportByDevice (from, to, userData, traccarInstance) {
44
44
  }
45
45
 
46
46
  if (isClientSide() && allDevices.length > 50 && userData.groupByDay) {
47
- const sliced = automaticReports.sliceArray(allDevices, 20)
47
+ const sliced = automaticReports.sliceArray(allDevices, 1)
48
48
  await executeServerSide('kms-report', allData, sliced, from, to, userData, allDevices.length)
49
49
  } else {
50
50
  let deviceCount = 0
@@ -214,4 +214,14 @@ function calculateRPMSections (route, min, max) {
214
214
  return sections
215
215
  }
216
216
 
217
+ function exportPerformanceReportToPDF (userData, reportData) {
218
+
219
+ }
220
+
221
+ function exportPerformanceReportToExcel (userData, reportData) {
222
+
223
+ }
224
+
217
225
  exports.createPerformanceReport = createPerformanceReport
226
+ exports.exportPerformanceReportToPDF = exportPerformanceReportToPDF
227
+ exports.exportPerformanceReportToExcel = exportPerformanceReportToExcel
@@ -45,18 +45,19 @@ describe('zones', function () {
45
45
 
46
46
  // eslint-disable-next-line no-undef
47
47
  it('works with casais zones in columns', async () => {
48
- const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
48
+ const report = await getReports('fleetmap.joao.penas2@gmail.com', 'penas46881')
49
49
  const userData = await report.getUserData()
50
50
  userData.zonesByColumn = true
51
- userData.devices = userData.devices.filter(d => d.name === 'G-1101-E Clio')
52
- userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ')
53
- userData.onlyWithKmsOut = true
51
+ userData.devices = userData.devices.filter(d => d.id === 81202)
52
+ userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ' ||
53
+ g.name === 'baliza 2 - raio amarelo')
54
+ userData.onlyWithKmsOut = false
54
55
  const result = await report.zoneReport(
55
- new Date(Date.UTC(2023, 0, 1, 0, 0, 0, 0)),
56
- new Date(Date.UTC(2023, 0, 31, 23, 59, 59, 0)),
56
+ new Date(Date.UTC(2023, 6, 13, 0, 0, 0, 0)),
57
+ new Date(Date.UTC(2023, 6, 13, 23, 59, 59, 0)),
57
58
  userData)
58
- const first = result[0].devices[0].days[0]
59
+ const first = result[0].devices[0]
59
60
  console.log(first)
60
- assert.equal(first.distanceOut, 35.52274536571346)
61
+ assert.equal(first.days[0].distanceOut, 28)
61
62
  }, 4000000)
62
63
  })
package/src/util/utils.js CHANGED
@@ -227,21 +227,25 @@ function weekDaySelected (date, weekDays) {
227
227
  async function executeServerSide (type, allData, sliced, from, to, userData, totalDevices) {
228
228
  let deviceCount = 0
229
229
  console.log('PROGRESS_PERC:1')
230
- const maxRequests = 4
231
- for (let i=0; i < sliced.length; i+=maxRequests) {
232
- const _sliced = sliced.slice(i, i+maxRequests)
230
+ const maxRequests = 10
231
+ for (let i = 0; i < sliced.length; i += maxRequests) {
232
+ const _sliced = sliced.slice(i, i + maxRequests)
233
233
  await Promise.all(_sliced.map(async devices => {
234
234
  const url = `https://${process.env.SERVER_HOST}/reports/${type}`
235
- const data = await axios.post(url, {
236
- from,
237
- to,
238
- userData: {
239
- ...userData,
240
- devices
241
- }
242
- }, { withCredentials: true }).then(d => d.data)
243
- allData.devices.push(...(data[0].devices))
244
- deviceCount = deviceCount + devices.length
235
+ try {
236
+ const data = await axios.post(url, {
237
+ from,
238
+ to,
239
+ userData: {
240
+ ...userData,
241
+ devices
242
+ }
243
+ }, { withCredentials: true }).then(d => d.data)
244
+ allData.devices.push(...(data[0].devices))
245
+ deviceCount = deviceCount + devices.length
246
+ } catch (e) {
247
+ console.error(e)
248
+ }
245
249
  console.log(`PROGRESS_PERC:${deviceCount / totalDevices * 100}`)
246
250
  }))
247
251
  }