1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-25 17:40:31 +00:00

Fix for search

This commit is contained in:
OzzieIsaacs 2020-10-10 07:47:27 +02:00
parent 3dacdcc8bb
commit d70ded0993
2 changed files with 10 additions and 7 deletions

View File

@ -664,9 +664,6 @@ class CalibreDB():
def get_search_results(self, term, offset=None, order=None, limit=None): def get_search_results(self, term, offset=None, order=None, limit=None):
order = order or [Books.sort] order = order or [Books.sort]
pagination = None pagination = None
if offset != None and limit != None:
offset = int(offset)
limit_all = offset + int(limit)
term.strip().lower() term.strip().lower()
self.session.connection().connection.connection.create_function("lower", 1, lcase) self.session.connection().connection.connection.create_function("lower", 1, lcase)
q = list() q = list()
@ -682,7 +679,12 @@ class CalibreDB():
)).order_by(*order).all() )).order_by(*order).all()
result_count = len(result) result_count = len(result)
if offset != None and limit != None: if offset != None and limit != None:
offset = int(offset)
limit_all = offset + int(limit)
pagination = Pagination((offset / (int(limit)) + 1), limit, result_count) pagination = Pagination((offset / (int(limit)) + 1), limit, result_count)
else:
offset = 0
limit_all = result_count
return result[offset:limit_all], result_count, pagination return result[offset:limit_all], result_count, pagination
# Creates for all stored languages a translated speaking name in the array for the UI # Creates for all stored languages a translated speaking name in the array for the UI

View File

@ -1248,9 +1248,6 @@ def advanced_search():
def render_adv_search_results(term, offset=None, order=None, limit=None): def render_adv_search_results(term, offset=None, order=None, limit=None):
order = order or [db.Books.sort] order = order or [db.Books.sort]
pagination = None pagination = None
if offset != None and limit != None:
offset = int(offset)
limit_all = offset + int(limit)
cc = get_cc_columns(filter_config_custom_read=True) cc = get_cc_columns(filter_config_custom_read=True)
calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase) calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
@ -1391,11 +1388,15 @@ def render_adv_search_results(term, offset=None, order=None, limit=None):
# entries, result_count, pagination = calibre_db.get_search_results(term, offset, order, limit) # entries, result_count, pagination = calibre_db.get_search_results(term, offset, order, limit)
result_count = len(q) result_count = len(q)
if offset != None and limit != None: if offset != None and limit != None:
offset = int(offset)
limit_all = offset + int(limit)
pagination = Pagination((offset / (int(limit)) + 1), limit, result_count) pagination = Pagination((offset / (int(limit)) + 1), limit, result_count)
else:
offset = 0
limit_all = result_count
return render_title_template('search.html', return render_title_template('search.html',
adv_searchterm=searchterm, adv_searchterm=searchterm,
pagination=pagination, pagination=pagination,
# query=request.form,
entries=q[offset:limit_all], entries=q[offset:limit_all],
result_count=result_count, result_count=result_count,
title=_(u"search"), page="advsearch") title=_(u"search"), page="advsearch")