fleetmap-reports 1.0.975 → 1.0.976

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/trip-report.js +10 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.975",
3
+ "version": "1.0.976",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -180,12 +180,16 @@ async function processDevices (from, to, devices, data, userData, traccar) {
180
180
 
181
181
  if (userData.includeTemperature) {
182
182
  const tripRoute = deviceRoute.filter(p => trip.startTime <= p.fixTime && trip.endTime >= p.fixTime && p.attributes.temp1 !== 175)
183
- trip.maxTemp = tripRoute.reduce((a, b) => {
184
- return a && a > b.attributes.temp1 ? a : b.attributes.temp1
185
- })
186
- trip.minTemp = tripRoute.reduce((a, b) => {
187
- return a && a < b.attributes.temp1 ? a : b.attributes.temp1
188
- })
183
+ trip.maxTemp = tripRoute.length > 0
184
+ ? tripRoute.reduce((a, b) => {
185
+ return a && a > b.attributes.temp1 ? a : b.attributes.temp1
186
+ })
187
+ : 0
188
+ trip.minTemp = tripRoute.length > 0
189
+ ? tripRoute.reduce((a, b) => {
190
+ return a && a < b.attributes.temp1 ? a : b.attributes.temp1
191
+ })
192
+ : 0
189
193
  trip.avgTemp = tripRoute.length > 0
190
194
  ? (tripRoute.reduce((a, b) => {
191
195
  return a + b.attributes.temp1