From a53f83589d315f9156feef3479280550ffe8c040 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 17 May 2024 21:40:18 +0200 Subject: [PATCH] cli/search: clear some bugs --- worblehat/cli/subclis/search.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/worblehat/cli/subclis/search.py b/worblehat/cli/subclis/search.py index aff7499..8bb7d4a 100644 --- a/worblehat/cli/subclis/search.py +++ b/worblehat/cli/subclis/search.py @@ -13,6 +13,7 @@ class SearchCli(NumberedCmd): def __init__(self, sql_session: Session): super().__init__() self.sql_session = sql_session + self.result = None def do_search_all(self, _: str): @@ -57,11 +58,11 @@ class SearchCli(NumberedCmd): elif len(author) == 1: selected_author = author[0] print('Found author:') - print(f" {selected_author.name} ({sum(item.amount for item in selected_author.books)} items)") + print(f" {selected_author.name} ({sum(item.amount for item in selected_author.items)} items)") else: selector = NumberedItemSelector( items = author, - stringify = lambda author: f"{author.name} ({sum(item.amount for item in author.books)} items)", + stringify = lambda author: f"{author.name} ({sum(item.amount for item in author.items)} items)", ) selector.cmdloop() if selector.result is None: @@ -69,7 +70,7 @@ class SearchCli(NumberedCmd): selected_author = selector.result selector = NumberedItemSelector( - items = selected_author.books, + items = list(selected_author.items), stringify = lambda item: f"{item.name} ({item.isbn})", ) selector.cmdloop()