mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
parseTrip: handle stopL[] items without idx 🐛
This commit is contained in:
parent
11ca3b171a
commit
92fb29d687
1 changed files with 3 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const minBy = require('lodash/minBy')
|
const minBy = require('lodash/minBy')
|
||||||
const maxBy = require('lodash/maxBy')
|
const maxBy = require('lodash/maxBy')
|
||||||
|
const last = require('lodash/last')
|
||||||
|
|
||||||
const parseTrip = (ctx, t) => { // t = raw trip
|
const parseTrip = (ctx, t) => { // t = raw trip
|
||||||
const {profile} = ctx
|
const {profile} = ctx
|
||||||
|
@ -9,8 +10,8 @@ const parseTrip = (ctx, t) => { // t = raw trip
|
||||||
// pretend the trip is a leg in a journey
|
// pretend the trip is a leg in a journey
|
||||||
const fakeLeg = {
|
const fakeLeg = {
|
||||||
type: 'JNY',
|
type: 'JNY',
|
||||||
dep: minBy(t.stopL, 'idx'),
|
dep: minBy(t.stopL, 'idx') || t.stopL[0],
|
||||||
arr: maxBy(t.stopL, 'idx'),
|
arr: maxBy(t.stopL, 'idx') || last(t.stopL),
|
||||||
jny: t,
|
jny: t,
|
||||||
}
|
}
|
||||||
const trip = profile.parseJourneyLeg(ctx, fakeLeg, t.date)
|
const trip = profile.parseJourneyLeg(ctx, fakeLeg, t.date)
|
||||||
|
|
Loading…
Add table
Reference in a new issue