Skip to content

Commit

Permalink
bugfixes 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Mar 6, 2018
1 parent 3362b05 commit 34c5cd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions lib/api.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 34c5cd2

Please sign in to comment.