报表设置由覆盖改更新

This commit is contained in:
wuaho 2021-09-17 14:25:57 +08:00
parent ec7e579d42
commit 293f2853bb
2 changed files with 10 additions and 9 deletions

View File

@ -34,7 +34,8 @@ async def edit_show_report(
) -> schemas.Msg:
report_id = data_in.config.report_id
res = await crud.dashboard.update_one(db, {'_id': data_in.dashboard_id, 'reports.report_id': report_id},
{'$set': {f'reports.$.{k}': v for k, v in data_in.config.dict().items()}})
{'$set': {f'reports.$.{k}': v for k, v in
data_in.config.dict(skip_defaults=True).items()}})
if res.modified_count == 1:
return schemas.Msg(code=0, msg='ok', data=data_in.config)
elif res.modified_count == 0:

View File

@ -29,14 +29,14 @@ class DashboardDelete(BaseModel):
class Report(BaseModel):
name: str
report_id: str
graph_type: str
ascending: bool
model: str
graph_size: str
sort: int = 1
modelswitch: bool = False
name: str = None
report_id: str = None
graph_type: str = None
ascending: bool = None
model: str = None
graph_size: str = None
sort: int = None
modelswitch: bool = None
class EditShowReport(BaseModel):