Fix IndexError when Bikepoint doesn't exist in historical data

This commit is contained in:
Marcel Schwarz 2020-12-29 20:07:12 +01:00
parent 8947f9116e
commit 84c9016be4
2 changed files with 2 additions and 2 deletions

View File

@ -37,7 +37,7 @@ def get_dashboard(station_id):
JOIN bike_points b ON u.start_station_id = b.id_num
JOIN dashboard d ON u.start_station_id = d.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):

View File

@ -26,7 +26,7 @@ class StationDashboard(BaseModel):
@router.get("/", response_model=StationDashboard)
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):