fleetmap-reports 1.0.230 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.230",
3
+ "version": "1.0.234",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -3,7 +3,7 @@ const moment = require('moment')
3
3
  function sliceArray(longArray) {
4
4
  const arrayToSlice = longArray.slice()
5
5
 
6
- const size = 200
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 Index = require('./index')
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
- axiosCookieJarSupport(axios)
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
- test('speedingReport', async () => {
11
- const traccarConfig = {
12
- basePath: 'https://api.pinme.io/api',
13
- baseOptions: {
14
- withCredentials: true,
15
- jar: cookieJar
16
- }
17
- }
18
-
19
- await new SessionApi(traccarConfig, null, axios).sessionPost('-','-')
20
- const report = new Index(traccarConfig, axios)
21
- const userData = await report.getUserData()
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
 
@@ -237,10 +239,9 @@ function exportKmsReportToExcel(userData, reportData) {
237
239
 
238
240
  const headers = []
239
241
 
240
- if(userData.groupByDay){
242
+ if(userData.groupByDay) {
241
243
  headers.push(
242
244
  {label: translations.report.vehicle, value: 'name'},
243
-
244
245
  {label: translations.report.group, value: 'group'},
245
246
  {label: translations.report.date, value: 'date'},
246
247
  {label: translations.report.distance, value: 'distance'})
@@ -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
+