fleetmap-reports 1.0.946 → 1.0.947
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 +1 -1
- package/src/util/trips.js +6 -13
package/package.json
CHANGED
package/src/util/trips.js
CHANGED
|
@@ -111,32 +111,25 @@ function isPartialInsideTimetable (t, userData, route) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
async function getDataByDay (device, date, data, userData, traccarInstance) {
|
|
114
|
-
const fromByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
|
|
115
|
-
const toByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59)
|
|
116
|
-
const convertedFromByDay = isClientSide() ? fromByDay : convertFromLocal(fromByDay, userData.user.attributes.timezone)
|
|
117
|
-
const convertedToByDay = isClientSide() ? toByDay : convertFromLocal(toByDay, userData.user.attributes.timezone)
|
|
118
|
-
console.log(fromByDay, toByDay)
|
|
119
|
-
const tripsByDay = data.trips.filter(t => new Date(t.endTime) > convertedFromByDay && new Date(t.startTime) < convertedToByDay).map(t => {
|
|
120
|
-
return { ...t }
|
|
121
|
-
})
|
|
122
|
-
console.log(date, tripsByDay.length)
|
|
123
114
|
const startDateLocal = new Date(convertFromUTC(date, userData.user.attributes.timezone).toISOString().split('T')[0] + ' ' + userData.dayHours.startTime)
|
|
124
115
|
const endDateLocal = new Date(convertFromUTC(date, userData.user.attributes.timezone).toISOString().split('T')[0] + ' ' + userData.dayHours.endTime)
|
|
125
116
|
const startDate = isClientSide() ? startDateLocal : convertFromLocal(startDateLocal, userData.user.attributes.timezone)
|
|
126
117
|
const endDate = isClientSide() ? endDateLocal : convertFromLocal(endDateLocal, userData.user.attributes.timezone)
|
|
118
|
+
|
|
119
|
+
const tripsByDay = data.trips.filter(t => new Date(t.endTime) > startDate && new Date(t.startTime) < endDate).map(t => {
|
|
120
|
+
return { ...t }
|
|
121
|
+
})
|
|
122
|
+
|
|
127
123
|
for (const t of tripsByDay) {
|
|
128
124
|
await calculatePartialTrip(device, startDate, endDate, data.route, t, traccarInstance)
|
|
129
125
|
}
|
|
130
126
|
|
|
131
|
-
const routeByDay = data.route ? data.route.filter(p => (new Date(p.fixTime) >
|
|
127
|
+
const routeByDay = data.route ? data.route.filter(p => (new Date(p.fixTime) > startDate && new Date(p.fixTime) < endDate)) : []
|
|
132
128
|
return { tripsByDay, routeByDay }
|
|
133
129
|
}
|
|
134
130
|
|
|
135
131
|
function getKms (trips) {
|
|
136
132
|
const odometerKms = trips.length > 0 ? trips[trips.length - 1].endOdometer - trips[0].startOdometer : 0
|
|
137
|
-
if (trips.length > 0) {
|
|
138
|
-
console.log(trips[trips.length - 1].endOdometer, trips[0].startOdometer, odometerKms)
|
|
139
|
-
}
|
|
140
133
|
return odometerKms > 0 ? odometerKms : trips.filter(t => t.distance > 0).reduce((a, b) => a + b.distance, 0)
|
|
141
134
|
}
|
|
142
135
|
|