Fix IndexError when Bikepoint doesn't exist in historical data
This commit is contained in:
parent
8947f9116e
commit
84c9016be4
@ -37,7 +37,7 @@ def get_dashboard(station_id):
|
|||||||
JOIN bike_points b ON u.start_station_id = b.id_num
|
JOIN bike_points b ON u.start_station_id = b.id_num
|
||||||
JOIN dashboard d ON u.start_station_id = d.id
|
JOIN dashboard d ON u.start_station_id = d.id
|
||||||
WHERE u.start_station_id = ?"""
|
WHERE u.start_station_id = ?"""
|
||||||
return get_db_connection().execute(query, (station_id,)).fetchall()
|
return get_db_connection().execute(query, (station_id,)).fetchone()
|
||||||
|
|
||||||
|
|
||||||
def get_dashboard_to(station_id, start_date, end_date):
|
def get_dashboard_to(station_id, start_date, end_date):
|
||||||
|
@ -26,7 +26,7 @@ class StationDashboard(BaseModel):
|
|||||||
|
|
||||||
@router.get("/", response_model=StationDashboard)
|
@router.get("/", response_model=StationDashboard)
|
||||||
def get_general_dashboard(station_id: int):
|
def get_general_dashboard(station_id: int):
|
||||||
return api_database.get_dashboard(station_id)[0]
|
return api_database.get_dashboard(station_id) or {}
|
||||||
|
|
||||||
|
|
||||||
class StationDashboardTopStationsEntry(BaseModel):
|
class StationDashboardTopStationsEntry(BaseModel):
|
||||||
|
Loading…
Reference in New Issue
Block a user