fleetmap-reports 1.0.289 → 1.0.293

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/.idea/aws.xml ADDED
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="accountSettings">
4
+ <option name="activeProfile" value="profile:default" />
5
+ <option name="activeRegion" value="us-east-1" />
6
+ <option name="recentlyUsedProfiles">
7
+ <list>
8
+ <option value="profile:default" />
9
+ </list>
10
+ </option>
11
+ <option name="recentlyUsedRegions">
12
+ <list>
13
+ <option value="us-east-1" />
14
+ </list>
15
+ </option>
16
+ </component>
17
+ </project>
@@ -0,0 +1,7 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <ScalaCodeStyleSettings>
4
+ <option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
5
+ </ScalaCodeStyleSettings>
6
+ </code_scheme>
7
+ </component>
@@ -1,8 +1,9 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
2
+ <module type="JAVA_MODULE" version="4">
3
3
  <component name="NewModuleRootManager" inherit-compiler-output="true">
4
4
  <exclude-output />
5
5
  <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
6
7
  <orderEntry type="sourceFolder" forTests="false" />
7
8
  </component>
8
9
  </module>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="JavaScriptLibraryMappings">
4
- <includedPredefinedLibrary name="Node.js Core" />
4
+ <file url="file://$PROJECT_DIR$" libraries="{Node.js Core}" />
5
5
  </component>
6
6
  </project>
package/.idea/modules.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <project version="4">
3
3
  <component name="ProjectModuleManager">
4
4
  <modules>
5
- <module fileurl="file://$PROJECT_DIR$/fleetmap-reports.iml" filepath="$PROJECT_DIR$/fleetmap-reports.iml" />
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/fleetmap-reports.iml" filepath="$PROJECT_DIR$/.idea/fleetmap-reports.iml" />
6
6
  </modules>
7
7
  </component>
8
8
  </project>
package/.idea/vcs.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
4
+ <mapping directory="" vcs="Git" />
5
5
  </component>
6
6
  </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.289",
3
+ "version": "1.0.293",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -19,7 +19,6 @@ const fileName = 'SpeedingReport'
19
19
  const eventTypes = ['deviceOverspeed']
20
20
 
21
21
  async function createSpeedingReport(from, to, reportUserData, traccar) {
22
- console.log('Create SpeedingReport')
23
22
  traccarInstance = traccar
24
23
  userData = reportUserData
25
24
  const reportData = []
@@ -34,7 +33,7 @@ async function createSpeedingReport(from, to, reportUserData, traccar) {
34
33
  const allData = await createSpeedingReportByGroup(from, to)
35
34
  reportData.push(...allData)
36
35
  } else {
37
- console.log("ByDevice")
36
+ console.log("createSpeedingReportByDevice")
38
37
  const allData = await createSpeedingReportByDevice(from, to, userData.devices)
39
38
  reportData.push(allData)
40
39
  }
@@ -239,9 +238,14 @@ async function getHereEvents(devices, routes, threshold){
239
238
  const events = []
240
239
  for (const d of devices) {
241
240
  const positions = routes.filter(p => p.deviceId === d.id)
241
+ if (!positions.length) {
242
+ console.log('no positions on device', d.name)
243
+ continue
244
+ }
245
+ let hereAlerts = null
242
246
  try {
243
247
  const results = await here.routeMatch(positions)
244
- const hereAlerts = results.filter(r => r.currentSpeedKmh > (parseInt(r.speedLimit) + threshold)).map(r => {
248
+ hereAlerts = results.filter(r => r.currentSpeedKmh > (parseInt(r.speedLimit) + threshold)).map(r => {
245
249
  const position = positions.find(p => new Date(p.fixTime).getTime() === r.timestamp)
246
250
  return {
247
251
  ...r,
@@ -252,6 +256,10 @@ async function getHereEvents(devices, routes, threshold){
252
256
  attributes: {speedLimit: r.speedLimit, speed: r.currentSpeedKmh / 1.85200}
253
257
  }
254
258
  })
259
+ if (!hereAlerts.length) {
260
+ console.log('empty array after filter on device', d.name)
261
+ continue
262
+ }
255
263
  const reduced = hereAlerts.reduce((acc, cur, idx, src) => {
256
264
  if (idx === 1) {
257
265
  return [cur]
@@ -263,7 +271,7 @@ async function getHereEvents(devices, routes, threshold){
263
271
  })
264
272
  events.push(...reduced)
265
273
  } catch (e) {
266
- console.error(e)
274
+ console.error(hereAlerts, e)
267
275
  }
268
276
  }
269
277
  return events