Skip to content

Commit

Permalink
register only if there are results
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoaquim committed May 14, 2024
1 parent 588461b commit e40ba23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cli/openbb_cli/argparse_translator/obbject_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions cli/openbb_cli/controllers/base_platform_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand All @@ -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)
Expand Down

0 comments on commit e40ba23

Please sign in to comment.