Skip to content

Commit

Permalink
proper checking of max_obbjects_exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoaquim committed May 10, 2024
1 parent b960c16 commit 03915f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 2 additions & 6 deletions cli/openbb_cli/controllers/base_platform_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@ def method(self, other_args: List[str], translator=translator):
title = f"{self.PATH}{translator.func.__name__}"

if obbject:
max_obbjects_exceeded = (
len(session.obbject_registry.obbjects)
>= session.settings.N_TO_KEEP_OBBJECT_REGISTRY
)
if max_obbjects_exceeded:
if session.max_obbjects_exceeded():
session.obbject_registry.remove()

# use the obbject to store the command so we can display it later on results
Expand Down Expand Up @@ -214,7 +210,7 @@ def method(self, other_args: List[str], translator=translator):
figure=fig,
)

if max_obbjects_exceeded:
if session.max_obbjects_exceeded():
session.console.print(
"[yellow]\nMaximum number of OBBjects reached. The oldest entry was removed.[yellow]"
)
Expand Down
6 changes: 6 additions & 0 deletions cli/openbb_cli/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ def is_local(self) -> bool:

def reset(self) -> None:
pass

def max_obbjects_exceeded(self) -> bool:
"""Check if max obbjects exceeded."""
return (
len(self.obbject_registry.all) >= self.settings.N_TO_KEEP_OBBJECT_REGISTRY
)

0 comments on commit 03915f8

Please sign in to comment.