fleetmap-reports 1.0.233 → 1.0.234
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 +1 -1
- package/src/automaticReports.js +1 -1
- package/src/index.test.js +18 -25
- package/src/kms-report.js +2 -0
- package/src/location-report.js +1 -1
- package/src/tests/index.js +22 -0
package/package.json
CHANGED
package/src/automaticReports.js
CHANGED
|
@@ -3,7 +3,7 @@ const moment = require('moment')
|
|
|
3
3
|
function sliceArray(longArray) {
|
|
4
4
|
const arrayToSlice = longArray.slice()
|
|
5
5
|
|
|
6
|
-
const size =
|
|
6
|
+
const size = 10
|
|
7
7
|
const arrayOfArrays = []
|
|
8
8
|
for (let i=0; i<arrayToSlice.length; i+=size) {
|
|
9
9
|
arrayOfArrays.push(arrayToSlice.slice(i,i+size));
|
package/src/index.test.js
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
const
|
|
2
|
-
const {SessionApi} = require("traccar-api");
|
|
3
|
-
const axios = require('axios')
|
|
4
|
-
const axiosCookieJarSupport = require('axios-cookiejar-support').default;
|
|
5
|
-
const tough = require('tough-cookie');
|
|
6
|
-
const cookieJar = new tough.CookieJar();
|
|
1
|
+
const {getReports} = require("./tests");
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
describe('speedingReport', function() {
|
|
4
|
+
this.timeout(500000)
|
|
5
|
+
it('test speeding', async () => {
|
|
6
|
+
const report = await getReports()
|
|
7
|
+
const userData = await report.getUserData()
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
await report.speedingReport(new Date(2021, 2, 30, 0, 0, 0, 0),
|
|
24
|
-
new Date(2021, 2, 30, 23, 59, 59, 0),
|
|
25
|
-
userData)
|
|
26
|
-
|
|
27
|
-
}, 10000)
|
|
9
|
+
await report.speedingReport(new Date(2021, 2, 30, 0, 0, 0, 0),
|
|
10
|
+
new Date(2021, 2, 30, 23, 59, 59, 0),
|
|
11
|
+
userData)
|
|
12
|
+
})
|
|
13
|
+
it('test kmsReport by day', async () => {
|
|
14
|
+
const reports = await getReports()
|
|
15
|
+
const userData = await reports.getUserData()
|
|
16
|
+
userData.groupByDay = true
|
|
17
|
+
await reports.kmsReport(new Date(2021, 9), new Date(2021, 10),
|
|
18
|
+
userData)
|
|
19
|
+
})
|
|
20
|
+
})
|
package/src/kms-report.js
CHANGED
|
@@ -28,7 +28,9 @@ async function createKmsReportByDevice(from, to, userData) {
|
|
|
28
28
|
const arrayOfArrays = automaticReports.sliceArray(devicesToSlice)
|
|
29
29
|
let data = []
|
|
30
30
|
for (const a of arrayOfArrays) {
|
|
31
|
+
console.log('getting',from,to,a.map(a => a.id))
|
|
31
32
|
const response = await traccarInstance.reports.reportsRouteGet(from, to, a.map(d => d.id))
|
|
33
|
+
console.log('concat', response.data.length)
|
|
32
34
|
data = data.concat(response.data)
|
|
33
35
|
}
|
|
34
36
|
|
package/src/location-report.js
CHANGED
|
@@ -139,7 +139,7 @@ async function exportLocationReportToPDF(userData, reportData) {
|
|
|
139
139
|
doc.text(new Date(d.from).toLocaleString() + ' - ' + new Date(d.to).toLocaleString(), 20, space + 25)
|
|
140
140
|
d.positions.map(a => {
|
|
141
141
|
const temp = [
|
|
142
|
-
a.
|
|
142
|
+
getLocationDate(a, userData.user),
|
|
143
143
|
a.address,
|
|
144
144
|
Math.round(a.speed * 1.85200),
|
|
145
145
|
a.attributes.ignition ? translations.report.ignitionOn : translations.report.ignitionOff,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const {SessionApi} = require("traccar-api");
|
|
2
|
+
const axios = require('axios')
|
|
3
|
+
const axiosCookieJarSupport = require('axios-cookiejar-support').default;
|
|
4
|
+
const tough = require('tough-cookie');
|
|
5
|
+
const Index = require('../index');
|
|
6
|
+
const cookieJar = new tough.CookieJar();
|
|
7
|
+
const traccarConfig = {
|
|
8
|
+
basePath: 'https://api.pinme.io/api',
|
|
9
|
+
baseOptions: {
|
|
10
|
+
withCredentials: true,
|
|
11
|
+
jar: cookieJar
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
axiosCookieJarSupport(axios)
|
|
16
|
+
|
|
17
|
+
exports.getReports = async() => {
|
|
18
|
+
await new SessionApi(traccarConfig, null, axios).sessionPost(process.env.email, process.env.password)
|
|
19
|
+
return new Index(traccarConfig, axios)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|