Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crypto/disc/top sort #4167

Merged
merged 3 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions openbb_terminal/cryptocurrency/discovery/discovery_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
)
from openbb_terminal.custom_prompt_toolkit import NestedCompleter
from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import EXPORT_ONLY_RAW_DATA_ALLOWED, check_positive
from openbb_terminal.helper_funcs import (
EXPORT_ONLY_RAW_DATA_ALLOWED,
check_positive,
)
from openbb_terminal.menu import session
from openbb_terminal.parent_classes import BaseController
from openbb_terminal.rich_config import MenuText, console, get_ordered_list_sources
Expand Down Expand Up @@ -52,6 +55,16 @@ def __init__(self, queue: List[str] = None):
if session and obbff.USE_PROMPT_TOOLKIT:
choices: dict = self.choices_default

ordered_list_sources_top = get_ordered_list_sources(f"{self.PATH}top")
if ordered_list_sources_top and ordered_list_sources_top[0] == "CoinGecko":
choices["top"]["--sort"] = {
c: {} for c in pycoingecko_view.COINS_COLUMNS
}
else:
choices["top"]["--sort"] = {c: {} for c in coinmarketcap_model.FILTERS}

choices["top"]["-s"] = choices["top"]["--sort"]

self.completer = NestedCompleter.from_nested_dict(choices)

def print_help(self):
Expand All @@ -78,11 +91,6 @@ def call_top(self, other_args):
else:
argument_sort_default = "CMC_Rank"

if ordered_list_sources_top and ordered_list_sources_top[0] == "CoinGecko":
argument_sort_choices = pycoingecko_view.COINS_COLUMNS
else:
argument_sort_choices = coinmarketcap_model.FILTERS

parser = argparse.ArgumentParser(
prog="top",
add_help=False,
Expand Down Expand Up @@ -121,7 +129,6 @@ def call_top(self, other_args):
nargs="+",
help="Sort by given column. Default: Market Cap Rank",
default=argument_sort_default,
choices=argument_sort_choices,
metavar="SORTBY",
)
parser.add_argument(
Expand Down
Loading