From cb5e66facd9713745239117119c84dce5f080fec Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 28 May 2023 13:11:50 +0200 Subject: [PATCH] add partial token set ratio to db --- cps/db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cps/db.py b/cps/db.py index 4f7dfaab..7c43ea8e 100644 --- a/cps/db.py +++ b/cps/db.py @@ -954,10 +954,10 @@ class CalibreDB: # read search results from calibre-database and return it (function is used for feed and simple search def get_search_results(self, term, config, offset=None, order=None, limit=None, *join): + self.session.connection().connection.connection.create_function("partial_token_set_ratio", 2, partial_token_set_ratio) order = order[0] if order else [Books.sort] pagination = None - result = self.search_query(term, config, *join).order_by(*order).all() - sorted(result,key=lambda book:1) + result = self.search_query(term, config, *join).order_by(func.desc(func.partial_token_set_ratio(str(Books),term))).all() for res in result: print(res[0]) result_count = len(result)