Skip to content

Commit

Permalink
fix: repeated call for trip_details broke it
Browse files Browse the repository at this point in the history
  • Loading branch information
albertkun committed Aug 12, 2023
1 parent b1b06f2 commit 5b30e56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
8 changes: 6 additions & 2 deletions data-loading-service/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
try:
if os.path.isfile('app/secrets.py'):
print('Loading secrets from secrets.py')
from .secrets import load_secrets
load_secrets()
try:
from .secrets import load_secrets
load_secrets()
except ModuleNotFoundError:
logging.info('No secrets.py found, loading from environment variables')
pass
except ModuleNotFoundError:
logging.info('No secrets.py found, loading from environment variables')
pass
Expand Down
14 changes: 2 additions & 12 deletions fastapi/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ async def get_trip_detail(agency_id: AgencyIdEnum, vehicle_id: str, geojson:bool



@app.get("/{agency_id}/trip_detail/route_code/{route_code}",tags=["Real-Time data","Static Data"])
@app.get("/{agency_id}/trip_detail/route_code/{route_code}",tags=["Real-Time data"])
async def get_trip_detail_by_route_code(agency_id: AgencyIdEnum, route_code: str, geojson:bool=False,db: Session = Depends(get_db)):
result = crud.get_gtfs_rt_vehicle_positions_trip_data_by_route_code(db,route_code,geojson,agency_id.value)
# crud.get_gtfs_rt_vehicle_positions_by_field_name(db,vehicle_id,geojson,agency_id.value)
Expand Down Expand Up @@ -340,7 +340,7 @@ async def get_line_detail_updates_for_route_code(websocket: WebSocket,agency_id:
await websocket.close()

@app.get("/{agency_id}/trip_detail_route_code/{route_code}",tags=["Real-Time data"])
async def get_trip_detail(agency_id: AgencyIdEnum, route_code: str, geojson:bool=False,db: Session = Depends(get_db)):
async def get_trip_detail_and_route_code(agency_id: AgencyIdEnum, route_code: str, geojson:bool=False,db: Session = Depends(get_db)):
result_array = []
temp_result = crud.get_gtfs_rt_vehicle_positions_trip_data_by_route_code(db,route_code,geojson,agency_id.value)
if len(temp_result) == 0:
Expand Down Expand Up @@ -507,16 +507,6 @@ async def live_get_gtfs_rt_trip_details(websocket: WebSocket,agency_id: AgencyId
# await websocket.send_json(payload)
# await asyncio.sleep(10)

@app.get("/{agency_id}/trip_detail_route_code/{route_code}",tags=["Real-Time data"])
async def get_trip_detail(agency_id: AgencyIdEnum, route_code: str, geojson:bool=False,db: Session = Depends(get_db)):
result_array = []
temp_result = crud.get_gtfs_rt_vehicle_positions_trip_data_by_route_code(db,route_code,geojson,agency_id.value)
if len(temp_result) == 0:
temp_result = { "message": "route'" + route_code + "' has no live trips'" }
return temp_result
result_array.append(temp_result)
return result_array

# Frontend Routing
@app.get("/websocket_test")
def read_root(request: Request):
Expand Down

0 comments on commit 5b30e56

Please sign in to comment.