fleetmap-reports 2.0.124 → 2.0.125

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.124",
3
+ "version": "2.0.125",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@ async function createDelayedStartReport (from, to, userData, traccar) {
22
22
  const sliced = automaticReports.sliceArray(devices, 5)
23
23
  let deviceCount = 0
24
24
  for (const slice of sliced) {
25
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, false, true, true, false, deviceCount, devices.length)
25
+ const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, false, false, deviceCount, devices.length)
26
26
 
27
27
  for (const d of slice) {
28
28
  const deviceData = await processDeviceData(from, to, allInOne, d, userData, traccar)
@@ -60,6 +60,8 @@ function getDelayDescription (startTime, activityStart, lowDelay, mediumDelay, h
60
60
 
61
61
  async function processDeviceData (from, to, allInOne, d, userData, traccar) {
62
62
  const trips = allInOne.trips.filter(t => t.deviceId === d.id)
63
+ const route = allInOne.route.filter(t => t.deviceId === d.id)
64
+
63
65
  const translations = getTranslations(userData)
64
66
 
65
67
  const weekDays = [
@@ -76,12 +78,26 @@ async function processDeviceData (from, to, allInOne, d, userData, traccar) {
76
78
 
77
79
  const days = []
78
80
  for (const date of dates) {
79
- const { tripsByDay } = await getDataByDay(d, date, { trips }, userData, traccar)
81
+ const { tripsByDay, routeByDay } = await getDataByDay(d, date, { trips, route }, userData, traccar)
82
+
83
+ let startTime
84
+ let endTime
85
+ if (userData.useIgnition) {
86
+ const firstIgnitionOn = routeByDay.find(p => p.attributes.ignition)
87
+ if (firstIgnitionOn) {
88
+ startTime = firstIgnitionOn.fixTime
89
+ }
90
+ } else {
91
+ if (tripsByDay.length) {
92
+ startTime = tripsByDay[0].startTime
93
+ }
94
+ }
80
95
 
81
- if (tripsByDay.length > 0) {
82
- const startTime = tripsByDay[0].startTime
83
- const endTime = tripsByDay[tripsByDay.length - 1].endTime
96
+ if (tripsByDay.length) {
97
+ endTime = tripsByDay[tripsByDay.length - 1].endTime
98
+ }
84
99
 
100
+ if (startTime) {
85
101
  const deviceDayData = {
86
102
  device: d.name,
87
103
  groupId: d.groupId,