From e40ba2384d8b0c8c1794bd077921028e47732765 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Tue, 14 May 2024 14:20:53 +0100 Subject: [PATCH] register only if there are results --- cli/openbb_cli/argparse_translator/obbject_registry.py | 6 ++++-- cli/openbb_cli/controllers/base_platform_controller.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/openbb_cli/argparse_translator/obbject_registry.py b/cli/openbb_cli/argparse_translator/obbject_registry.py index e1c73fd0c127..372254b4b545 100644 --- a/cli/openbb_cli/argparse_translator/obbject_registry.py +++ b/cli/openbb_cli/argparse_translator/obbject_registry.py @@ -20,8 +20,10 @@ def _contains_obbject(uuid: str, obbjects: List[OBBject]) -> bool: def register(self, obbject: OBBject) -> bool: """Designed to add an OBBject instance to the registry.""" - if isinstance(obbject, OBBject) and not self._contains_obbject( - obbject.id, self._obbjects + if ( + isinstance(obbject, OBBject) + and not self._contains_obbject(obbject.id, self._obbjects) + and obbject.results ): self._obbjects.append(obbject) return True diff --git a/cli/openbb_cli/controllers/base_platform_controller.py b/cli/openbb_cli/controllers/base_platform_controller.py index c59a9f17f17f..df67c708e148 100644 --- a/cli/openbb_cli/controllers/base_platform_controller.py +++ b/cli/openbb_cli/controllers/base_platform_controller.py @@ -160,7 +160,7 @@ def method(self, other_args: List[str], translator=translator): if obbject: if isinstance(obbject, OBBject): - if session.max_obbjects_exceeded(): + if session.max_obbjects_exceeded() and obbject.results: session.obbject_registry.remove() session.console.print( "[yellow]Maximum number of OBBjects reached. The oldest entry was removed.[yellow]" @@ -181,7 +181,9 @@ def method(self, other_args: List[str], translator=translator): session.settings.SHOW_MSG_OBBJECT_REGISTRY and register_result ): - session.console.print("Added OBBject to registry.") + session.console.print( + "Added `OBBject` to cached results." + ) # making the dataframe available # either for printing or exporting (or both)