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
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,
|
|
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
|
package/src/tests/zones.test.js
CHANGED
|
@@ -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(
|
|
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.
|
|
52
|
-
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde '
|
|
53
|
-
|
|
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,
|
|
56
|
-
new Date(Date.UTC(2023,
|
|
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]
|
|
59
|
+
const first = result[0].devices[0]
|
|
59
60
|
console.log(first)
|
|
60
|
-
assert.equal(first.distanceOut,
|
|
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 =
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
}
|