fleetmap-reports 1.0.253 → 1.0.255

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.
@@ -1,12 +1,11 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
- <list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="Trip and activity report with time period">
4
+ <list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="Fix trips distance because imported positions generate trips with 0 kms">
5
5
  <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
6
6
  <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
7
7
  <change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/src/kms-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/kms-report.js" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/src/trip-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/trip-report.js" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/src/util/trips.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/trips.js" afterDir="false" />
10
9
  </list>
11
10
  <option name="SHOW_DIALOG" value="false" />
12
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -213,7 +212,7 @@
213
212
  <workItem from="1639592539998" duration="27141000" />
214
213
  <workItem from="1639766010908" duration="4991000" />
215
214
  <workItem from="1639872937953" duration="1438000" />
216
- <workItem from="1639954341221" duration="7636000" />
215
+ <workItem from="1639954341221" duration="10241000" />
217
216
  </task>
218
217
  <task id="LOCAL-00001" summary="Fix getStyle">
219
218
  <created>1636983717385</created>
@@ -313,7 +312,14 @@
313
312
  <option name="project" value="LOCAL" />
314
313
  <updated>1639873766072</updated>
315
314
  </task>
316
- <option name="localTasksCounter" value="15" />
315
+ <task id="LOCAL-00015" summary="Fix trips distance because imported positions generate trips with 0 kms">
316
+ <created>1640000462824</created>
317
+ <option name="number" value="00015" />
318
+ <option name="presentableId" value="LOCAL-00015" />
319
+ <option name="project" value="LOCAL" />
320
+ <updated>1640000462825</updated>
321
+ </task>
322
+ <option name="localTasksCounter" value="16" />
317
323
  <servers />
318
324
  </component>
319
325
  <component name="TypeScriptGeneratedFilesManager">
@@ -345,6 +351,7 @@
345
351
  <MESSAGE value="speeding report with customSpeed" />
346
352
  <MESSAGE value="fix speeding report" />
347
353
  <MESSAGE value="Trip and activity report with time period" />
348
- <option name="LAST_COMMIT_MESSAGE" value="Trip and activity report with time period" />
354
+ <MESSAGE value="Fix trips distance because imported positions generate trips with 0 kms" />
355
+ <option name="LAST_COMMIT_MESSAGE" value="Fix trips distance because imported positions generate trips with 0 kms" />
349
356
  </component>
350
357
  </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.253",
3
+ "version": "1.0.255",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/util/trips.js CHANGED
@@ -1,16 +1,21 @@
1
1
  const traccar = require("./traccar");
2
2
 
3
+ const minDistance = 0
4
+ const minAvgSpeed = 0
5
+
3
6
  async function checkTripsKms(traccarInstance, from, to, routeData, tripsData, devices) {
4
7
  console.log('checkTripsKms')
5
- const trips = tripsData.filter(t => t.distance === 0 && t.averageSpeed > 10)
8
+ const trips = tripsData.filter(t => t.distance === minDistance && t.averageSpeed > minAvgSpeed)
6
9
  if(trips.length > 0) {
7
10
  //Vehicles with imported positions. calculate trip distance with route positions
8
11
  const route = routeData.length === 0 ? await traccar.getRoute(traccarInstance, from, to, devices) : routeData
9
12
  trips.forEach(t => {
10
- const tripRoute = route.filter(p => p.deviceId === t.deviceId
11
- && new Date(p.fixTime).getTime() > new Date(t.startTime).getTime()
12
- && new Date(p.fixTime).getTime() < new Date(t.endTime).getTime())
13
- t.distance = tripRoute.reduce((a, b) => a + b.attributes.distance, 0)
13
+ if(t.distance === minDistance && t.averageSpeed > minAvgSpeed) {
14
+ const tripRoute = route.filter(p => p.deviceId === t.deviceId
15
+ && new Date(p.fixTime).getTime() >= new Date(t.startTime).getTime()
16
+ && new Date(p.fixTime).getTime() <= new Date(t.endTime).getTime())
17
+ t.distance = tripRoute.reduce((a, b) => a + b.attributes.distance, 0)
18
+ }
14
19
  })
15
20
  }
16
21
  }