fleetmap-reports 2.0.48 → 2.0.50

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.48",
3
+ "version": "2.0.50",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,7 +1,8 @@
1
1
  const jsPDF = require('jspdf')
2
2
  const {
3
3
  convertMS, convertToLocaleString, convertToFeature, convertPositionToFeature, getTranslations, getLanguage,
4
- getCountry
4
+ getCountry,
5
+ getServerHost
5
6
  } = require('./util/utils')
6
7
  const { headerFromUser, AmiriRegular } = require('./util/pdfDocument')
7
8
  require('jspdf-autotable')
@@ -20,7 +21,6 @@ const booleanPointInPolygon = require('@turf/boolean-point-in-polygon')
20
21
  const automaticReports = require('./automaticReports')
21
22
  const { default: axios } = require('axios')
22
23
  const { getDriverName, getDriverData } = require('./util/driver')
23
- const { getServerHost } = require('./util')
24
24
 
25
25
  const fileName = 'SpeedingReport'
26
26
  const eventTypes = ['deviceOverspeed']
@@ -385,7 +385,7 @@ async function invokeValhalla (route, i, chunk, country, threshold, results, ret
385
385
  }
386
386
 
387
387
  async function getOSMSpeedingEvents (devices, routes, threshold, minimumMinutes = 0, country) {
388
- const chunk = 200
388
+ const chunk = 100
389
389
  const events = []
390
390
  for (const d of devices) {
391
391
  const route = routes.filter(r => r.deviceId === d.id)
package/src/util/utils.js CHANGED
@@ -1,8 +1,11 @@
1
1
  const turf = require('@turf/helpers')
2
- const { getUserPartner } = require('fleetmap-partners')
2
+ const {
3
+ getUserPartner,
4
+ newDomains
5
+ } = require('fleetmap-partners')
3
6
  const messages = require('../../lang')
4
7
  const distance = require('@turf/distance')
5
- const { getServerHost } = require('./index')
8
+ const { devicesToProcess } = require('./device')
6
9
 
7
10
  exports.getTranslations = (userData) => {
8
11
  const lang = this.getLanguage(userData)
@@ -318,3 +321,14 @@ exports.getCountry = (position) => {
318
321
  }
319
322
  return country && country.code
320
323
  }
324
+
325
+ exports.processServerSide = (userData) => {
326
+ const devices = devicesToProcess(userData)
327
+ return devices.length > 100 && isClientSide()
328
+ }
329
+
330
+ const getServerHost = () =>
331
+ newDomains.includes(window.location.hostname)
332
+ ? `${window.location.hostname}/pinmeapi`
333
+ : process.env.SERVER_HOST
334
+ exports.getServerHost = getServerHost
@@ -4,7 +4,8 @@ const {
4
4
  calculateDistance,
5
5
  sortPositions, getDates, convertToLocaleDateString, convertToLocaleTimeString,
6
6
  isClientSide,
7
- getLanguage, convertFromUTC, convertFromLocal
7
+ getLanguage, convertFromUTC, convertFromLocal,
8
+ getServerHost
8
9
  } = require('./util/utils')
9
10
  const jsPDF = require('jspdf')
10
11
  require('jspdf-autotable')
@@ -22,7 +23,6 @@ const {
22
23
  const { checkGeofenceIn } = require('./util/geofence')
23
24
  const { parallel } = require('./util/parallel')
24
25
  const { getDataByDay } = require('./util/trips')
25
- const { getServerHost } = require('./util')
26
26
  const sliceSize = 100
27
27
  const deviceChunk = 5
28
28
  const fileName = 'ZoneReport'
package/src/util/index.js DELETED
@@ -1,13 +0,0 @@
1
- const { devicesToProcess } = require('./device')
2
- const { isClientSide } = require('./utils')
3
- const { newDomains } = require('fleetmap-partners')
4
-
5
- exports.processServerSide = (userData) => {
6
- const devices = devicesToProcess(userData)
7
- return devices.length > 100 && isClientSide()
8
- }
9
-
10
- exports.getServerHost = () =>
11
- newDomains.includes(window.location.hostname)
12
- ? `${window.location.hostname}/pinmeapi`
13
- : process.env.SERVER_HOST