42Cummer commited on
Commit
00f5c2a
·
verified ·
1 Parent(s): 1d8fe63

Upload app.py

Browse files
Files changed (1) hide show
  1. src/app.py +12 -2
src/app.py CHANGED
@@ -234,12 +234,14 @@ async def get_vehicle_view(vehicle_id: str):
234
  @app.get("/api/stop/{stop_code}")
235
  async def get_stop_view(stop_code: str):
236
  # 1. Translate Pole Number to Database ID
237
- stop_info = db.execute("SELECT stop_id, stop_name FROM stops WHERE CAST(stop_code AS VARCHAR) = ? LIMIT 1", [str(stop_code)]).fetchone()
238
  if not stop_info:
239
  return {"error": "Stop code not found"}
240
 
241
  target_id = str(stop_info[0])
242
  stop_name = stop_info[1]
 
 
243
 
244
  # 2. Get the Cache structure (dict with vehicles, predictions, alerts)
245
  cached_data = await ttc_cache.get_data()
@@ -295,7 +297,15 @@ async def get_stop_view(stop_code: str):
295
  })
296
 
297
  arrivals.sort(key=lambda x: x['eta_mins'])
298
- return {"stop_name": stop_name, "stop_code": stop_code, "arrivals": arrivals}
 
 
 
 
 
 
 
 
299
 
300
  @app.get("/api/alerts")
301
  async def get_all_alerts():
 
234
  @app.get("/api/stop/{stop_code}")
235
  async def get_stop_view(stop_code: str):
236
  # 1. Translate Pole Number to Database ID
237
+ stop_info = db.execute("SELECT stop_id, stop_name, stop_lat, stop_lon FROM stops WHERE CAST(stop_code AS VARCHAR) = ? LIMIT 1", [str(stop_code)]).fetchone()
238
  if not stop_info:
239
  return {"error": "Stop code not found"}
240
 
241
  target_id = str(stop_info[0])
242
  stop_name = stop_info[1]
243
+ stop_lat = stop_info[2]
244
+ stop_lon = stop_info[3]
245
 
246
  # 2. Get the Cache structure (dict with vehicles, predictions, alerts)
247
  cached_data = await ttc_cache.get_data()
 
297
  })
298
 
299
  arrivals.sort(key=lambda x: x['eta_mins'])
300
+ return {
301
+ "stop_name": stop_name,
302
+ "stop_code": stop_code,
303
+ "location": {
304
+ "lat": stop_lat,
305
+ "lon": stop_lon
306
+ },
307
+ "arrivals": arrivals
308
+ }
309
 
310
  @app.get("/api/alerts")
311
  async def get_all_alerts():