修正报表排序

This commit is contained in:
wuaho 2021-10-11 14:58:27 +08:00
parent 6bd203997a
commit 1d96278818

View File

@ -83,11 +83,9 @@ async def read_report(
dashboard = await crud.dashboard.get(db, id=data_in.dashboard_id)
# projection = {'query': False}
projection = None
reports = await crud.report.read_report(db,project_id=data_in.project_id,
reports = await crud.report.read_report(db, project_id=data_in.project_id,
projection=projection, **ext_where)
for item in reports:
item['added'] = False
# item['name'] = item['name']
@ -96,7 +94,7 @@ async def read_report(
if item['_id'] in added_ids:
item['added'] = True
item['show_config'] = added_ids[item['_id']]
reports = sorted(reports, key=lambda x: x.get('show_config', {}).get('sort',999) or 999)
reports = sorted(reports, key=lambda x: x.get('show_config', {'sort': 999}).get('sort', 999))
return schemas.Msg(code=0, msg='ok', data=reports)