Refactor history_controller.py to handle empty request history

This commit is contained in:
sHa
2024-03-22 01:27:33 +02:00
parent 56125f0dbb
commit a5a290b1d7

View File

@@ -30,7 +30,14 @@ class HistoryController(BaseController):
message="No requests found.",
)
return RequestData(**item)
return [RequestData(**d) for d in history.all()]
items = history.all()
if items is None:
return Answer(
status=Status.error,
message="No requests found.",
)
return [RequestData(**d) for d in items ]
async def last_requests(
self,