From a5a290b1d73e6d5877d0bb87aa0b144ead70bbc7 Mon Sep 17 00:00:00 2001 From: sHa Date: Fri, 22 Mar 2024 01:27:33 +0200 Subject: [PATCH] Refactor history_controller.py to handle empty request history --- controller/history_controller.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/controller/history_controller.py b/controller/history_controller.py index 2a650e4..d250124 100644 --- a/controller/history_controller.py +++ b/controller/history_controller.py @@ -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,