latestLocation = [...Object.entries(tripsData)].reduce(
(acc, tripObj) => {
const [tripId, trip] = tripObj
const {id, direction, serviceDate, locations} = trip
const location = locations[locations.length - 1]
const time = new Date(location.time * 1000)
location.stale = Date.now() - time
if (location.stale < (10 * 60 * 1000)) {
acc.push({
id, direction, serviceDate, ...location, time
})
}
return acc
},
[]
)