fleetmap-reports 2.0.248 → 2.0.249

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.248",
3
+ "version": "2.0.249",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -385,9 +385,11 @@ async function getOSMSpeedingEvents (devices, routes, threshold, minimumMinutes
385
385
  for (const d of devices) {
386
386
  const route = routes.filter(r => r.deviceId === d.id)
387
387
  const results = []
388
+ const promises = []
388
389
  for (let i = 0; i < route.length; i += chunk) {
389
- await invokeValhalla(route, i, chunk, country, threshold, results)
390
+ promises.push(invokeValhalla(route, i, chunk, country, threshold, results))
390
391
  }
392
+ await Promise.all(promises)
391
393
  const reduced = results.reduce((acc, cur, idx, src) => {
392
394
  const last = acc.length && acc.slice(-1)[0]
393
395
  if (last && new Date(cur.fixTime) - new Date(src[idx - 1].fixTime) < 1000 * 60 * 2) {
@@ -13,12 +13,7 @@ process.env.TRACCAR_API_REPORTS = 'https://ltqgfyvcklxzaonv7h4rlmghai0rszop.lamb
13
13
  process.env.SERVER_HOST = 'api.pinme.io'
14
14
  const getReports = async (email, password) => {
15
15
  try {
16
- email = email || process.env.email
17
- password = password || process.env.password
18
- console.log('email / pass', email, password)
19
- const formData = `email=${encodeURIComponent(email)}&password=${encodeURIComponent(password)}`
20
- const [cookie] = (await axios.post('/session', formData)).headers['set-cookie']
21
- axios.defaults.headers.common.cookie = cookie
16
+ axios.defaults.headers.common.cookie = process.env.COOKIE
22
17
  return new Index(traccarConfig, axios)
23
18
  } catch (e) {
24
19
  console.error(e)
@@ -4,8 +4,8 @@ const { getCountry } = require('../util/utils')
4
4
 
5
5
  async function getSpeedingReport (report, userData) {
6
6
  const data = await report.speedingReport(
7
- new Date(Date.UTC(2025, 4, 5, 0, 0, 0, 0)),
8
- new Date(Date.UTC(2025, 4, 5, 23, 59, 59, 0)),
7
+ new Date(Date.UTC(2025, 4, 1, 0, 0, 0, 0)),
8
+ new Date(Date.UTC(2025, 4, 31, 23, 59, 59, 0)),
9
9
  userData)
10
10
 
11
11
  const device = data[0].devices[0]
@@ -19,16 +19,11 @@ describe('speeding tests', function () {
19
19
  it('works with road speed limits in Chile', async () => {
20
20
  const report = await getReports(process.env.USER_CHILE, process.env.PASS_CHILE)
21
21
  const userData = await report.getUserData()
22
- userData.devices = [userData.devices[0]]
22
+ // userData.devices = [userData.devices[0]]
23
23
  userData.roadSpeedLimits = true
24
24
  const { device } = await getSpeedingReport(report, userData)
25
25
  assert.equal(device.alerts.length, 6) // Total Alerts
26
26
  console.log(device.alerts)
27
-
28
- userData.minimumIdleMinutes = 1
29
- const r = await getSpeedingReport(report, userData)
30
- r.device.alerts.forEach(a => assert.equal(true, a.eventTime >= 60000))
31
- assert.equal(r.device.alerts.length, 2) // Total Alerts
32
27
  }, 200000)
33
28
 
34
29
  // eslint-disable-next-line no-undef