From 34c5cd2982f2a91ccff5507ff8d16824ff452925 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 6 Mar 2018 03:33:15 +0100 Subject: [PATCH] bugfixes :bug: --- lib/api.js | 17 +++++++++++++++-- lib/render.js | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/api.js b/lib/api.js index beeda49..2609c23 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,14 +1,27 @@ 'use strict' const search = require('vbb-stations-autocomplete') +const getStations = require('vbb-stations') const client = require('vbb-client') const location = (query) => { const [station1] = search(query, 1, false, false) - if (station1) return Promise.resolve(station1) + if (station1) { + const [s] = getStations(station1.id) + if (s) { + Object.assign(station1, s) + return Promise.resolve(station1) + } + } const [station2] = search(query, 1, true, false) // fuzzy - if (station2) return Promise.resolve(station2) + if (station2) { + const [s] = getStations(station2.id) + if (s) { + Object.assign(station2, s) + return Promise.resolve(station2) + } + } return client.locations(query, { results: 1, identifier: 'vbb-telegram' diff --git a/lib/render.js b/lib/render.js index 63066cd..e6d0989 100644 --- a/lib/render.js +++ b/lib/render.js @@ -71,7 +71,7 @@ const journey = (r) => { return 'From ' + (r.origin.name ? r.origin.name : coords(r.origin)) + ' to ' + (r.destination.name ? r.destination.name : coords(r.destination)) + ` in ${ms(r.arrival - r.departure)}.\n` - + r.parts.reduce(part, '') + + r.legs.reduce(part, '') } const journeys = (r) => {