Provide station name even if no departures. Fixes #2

This commit is contained in:
RunasSudo 2019-01-13 23:05:46 +11:00
parent e461314187
commit 1b07e4f91b
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -191,6 +191,9 @@ def latest():
if len(departures['departures']) == 0: if len(departures['departures']) == 0:
# Invalid stop ID, platform ID, no departures, etc. # Invalid stop ID, platform ID, no departures, etc.
# Set stop name manually
get_station_list()
result['stop_name'] = next((v for k, v in stns if k == int(flask.request.args['stop_id'])), 'Unknown station')
return flask.jsonify(result) return flask.jsonify(result)
result['stop_name'] = stop_to_name(departures['stops'][flask.request.args['stop_id']], None) result['stop_name'] = stop_to_name(departures['stops'][flask.request.args['stop_id']], None)