From d0e15da352f4735b58e5ab5cc50ce3bce17e0deb Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Sat, 23 May 2020 12:51:48 +0200 Subject: [PATCH] Fix lcase function --- cps/db.py | 18 +++++++------- cps/web.py | 4 ++-- test/Calibre-Web TestSummary.html | 40 ++++++++----------------------- 3 files changed, 22 insertions(+), 40 deletions(-) diff --git a/cps/db.py b/cps/db.py index 5c487e43..f4b5ec96 100644 --- a/cps/db.py +++ b/cps/db.py @@ -546,14 +546,14 @@ class CalibreDB(threading.Thread): def get_typeahead(self, database, query, replace=('', ''), tag_filter=true()): query = query or '' - self.session.connection().connection.connection.create_function("lower", 1, self.lcase) + self.session.connection().connection.connection.create_function("lower", 1, lcase) entries = self.session.query(database).filter(tag_filter). \ filter(func.lower(database.name).ilike("%" + query + "%")).all() json_dumps = json.dumps([dict(name=r.name.replace(*replace)) for r in entries]) return json_dumps def check_exists_book(self, authr, title): - self.session.connection().connection.connection.create_function("lower", 1, self.lcase) + self.session.connection().connection.connection.create_function("lower", 1, lcase) q = list() authorterms = re.split(r'\s*&\s*', authr) for authorterm in authorterms: @@ -565,7 +565,7 @@ class CalibreDB(threading.Thread): # read search results from calibre-database and return it (function is used for feed and simple search def get_search_results(self, term): term.strip().lower() - self.session.connection().connection.connection.create_function("lower", 1, self.lcase) + self.session.connection().connection.connection.create_function("lower", 1, lcase) q = list() authorterms = re.split("[, ]+", term) for authorterm in authorterms: @@ -642,8 +642,10 @@ class CalibreDB(threading.Thread): self.engine.dispose() self.setup_db(config, app_db_path) - def lcase(self, s): - try: - return unidecode.unidecode(s.lower()) - except Exception as e: - self.log.exception(e) +def lcase(s): + try: + return unidecode.unidecode(s.lower()) + except Exception as e: + log = logger.create() + log.exception(e) + return s.lower() diff --git a/cps/web.py b/cps/web.py index e2ef8e99..5b4b014a 100644 --- a/cps/web.py +++ b/cps/web.py @@ -590,7 +590,7 @@ def get_languages_json(): def get_matching_tags(): tag_dict = {'tags': []} q = calibre_db.session.query(db.Books) - calibre_db.session.connection().connection.connection.create_function("lower", 1, calibre_db.lcase) + calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase) author_input = request.args.get('author_name') or '' title_input = request.args.get('book_title') or '' include_tag_inputs = request.args.getlist('include_tag') or '' @@ -1020,7 +1020,7 @@ def search(): def advanced_search(): # Build custom columns names cc = get_cc_columns() - calibre_db.session.connection().connection.connection.create_function("lower", 1, calibre_db.lcase) + calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase) q = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()).order_by(db.Books.sort) include_tag_inputs = request.args.getlist('include_tag') diff --git a/test/Calibre-Web TestSummary.html b/test/Calibre-Web TestSummary.html index 8de86c9d..58884fcf 100755 --- a/test/Calibre-Web TestSummary.html +++ b/test/Calibre-Web TestSummary.html @@ -36,17 +36,17 @@
-

Start Time: 2020-05-22 07:43:12

+

Start Time: 2020-05-22 18:17:02

-

Stop Time: 2020-05-22 08:41:06

+

Stop Time: 2020-05-22 19:14:53

-

Duration: 48:51 min

+

Duration: 48:49 min

@@ -2219,8 +2219,8 @@ AssertionError: False is not true : logfile config value is not empty after rese test_visiblilitys.calibre_web_visibilitys 28 - 27 - 1 + 28 + 0 0 0 @@ -2410,31 +2410,11 @@ AssertionError: False is not true : logfile config value is not empty after rese - +
test_link_column_to_read_status
- -
- FAIL -
- - - - + PASS @@ -2505,8 +2485,8 @@ AssertionError: 1 != 0 Total 211 - 200 - 5 + 201 + 4 0 6   @@ -2734,7 +2714,7 @@ AssertionError: 1 != 0