From 92fb29d6875de870302a21ae68131361b8446fce Mon Sep 17 00:00:00 2001 From: Jannis R Date: Wed, 16 Sep 2020 16:46:22 +0200 Subject: [PATCH] =?UTF-8?q?parseTrip:=20handle=20stopL[]=20items=20without?= =?UTF-8?q?=20idx=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parse/trip.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parse/trip.js b/parse/trip.js index 1d5a96ab..49dc243d 100644 --- a/parse/trip.js +++ b/parse/trip.js @@ -2,6 +2,7 @@ const minBy = require('lodash/minBy') const maxBy = require('lodash/maxBy') +const last = require('lodash/last') const parseTrip = (ctx, t) => { // t = raw trip const {profile} = ctx @@ -9,8 +10,8 @@ const parseTrip = (ctx, t) => { // t = raw trip // pretend the trip is a leg in a journey const fakeLeg = { type: 'JNY', - dep: minBy(t.stopL, 'idx'), - arr: maxBy(t.stopL, 'idx'), + dep: minBy(t.stopL, 'idx') || t.stopL[0], + arr: maxBy(t.stopL, 'idx') || last(t.stopL), jny: t, } const trip = profile.parseJourneyLeg(ctx, fakeLeg, t.date)