Fix sorting of dashboard duration groups
Include all groups, even when they are zero
This commit is contained in:
parent
9cdae30f7e
commit
7a85fe933c
@ -56,7 +56,19 @@ class StationDashboardDurationGroup(BaseModel):
|
||||
@router.get("/duration", response_model=List[StationDashboardDurationGroup])
|
||||
def get_duration_dashboard_for_station(station_id: int, start_date: datetime.date, end_date: datetime.date):
|
||||
validate_daterange(start_date, end_date)
|
||||
return api_database.get_dashboard_duration(station_id, start_date, end_date)
|
||||
db_data = api_database.get_dashboard_duration(station_id, start_date, end_date)
|
||||
ret_val = []
|
||||
for group in ['0-5', '5-15', '15-30', '30-45', '45+']:
|
||||
curr_minute_group = list(filter(lambda x: x['minutesGroup'] == group, db_data))
|
||||
if curr_minute_group:
|
||||
item = curr_minute_group.pop()
|
||||
ret_val.append({
|
||||
'number': item['number'],
|
||||
'minutesGroup': item['minutesGroup']
|
||||
})
|
||||
else:
|
||||
ret_val.append({'number': 0, 'minutesGroup': group})
|
||||
return ret_val
|
||||
|
||||
|
||||
class StationDashboardTimeGroup(BaseModel):
|
||||
|
Loading…
Reference in New Issue
Block a user