mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
1) remove unrated items from rating
2) make rating:false (or somecustomcol:false) match unrated items 3) make rating:true match rated items
This commit is contained in:
parent
a1c9fa3671
commit
02d79e48cf
@ -281,6 +281,10 @@ class ResultCache(SearchQueryParser):
|
||||
matches = set([])
|
||||
if len(query) == 0:
|
||||
return matches
|
||||
if query == 'false':
|
||||
query = '0'
|
||||
elif query == 'true':
|
||||
query = '>0'
|
||||
relop = None
|
||||
for k in self.rating_search_relops.keys():
|
||||
if query.startswith(k):
|
||||
@ -298,8 +302,13 @@ class ResultCache(SearchQueryParser):
|
||||
loc = self.FIELD_MAP['rating']
|
||||
|
||||
for item in self._data:
|
||||
if item is None or item[loc] is None: continue
|
||||
if relop(item[loc]/2, r):
|
||||
if item is None:
|
||||
continue
|
||||
if not item[loc]:
|
||||
i = 0
|
||||
else:
|
||||
i = item[loc]/2
|
||||
if relop(i, r):
|
||||
matches.add(item[0])
|
||||
return matches
|
||||
|
||||
@ -312,13 +321,13 @@ class ResultCache(SearchQueryParser):
|
||||
if (location in ('pubdate', 'date')) or \
|
||||
((location in self.custom_column_label_map) and \
|
||||
self.custom_column_label_map[location]['datatype'] == 'datetime'):
|
||||
return self.get_dates_matches(location, query)
|
||||
return self.get_dates_matches(location, query.lower())
|
||||
|
||||
### take care of ratings special case
|
||||
if location == 'rating' or \
|
||||
((location in self.custom_column_label_map) and \
|
||||
self.custom_column_label_map[location]['datatype'] == 'rating'):
|
||||
return self.get_ratings_matches(location, query)
|
||||
return self.get_ratings_matches(location, query.lower())
|
||||
|
||||
### everything else
|
||||
matchkind = CONTAINS_MATCH
|
||||
|
@ -636,7 +636,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
||||
tooltip = self.custom_column_label_map[category]['name']
|
||||
formatter = self.tag_browser_formatters.get(tn, lambda x: x)
|
||||
categories[category] = [Tag(formatter(r[1]), count=r[2], id=r[0], icon=icon, tooltip = tooltip)
|
||||
for r in data if r[2] > 0]
|
||||
for r in data
|
||||
if r[2] > 0 and (category != 'rating' or len(formatter(r[1])) > 0)]
|
||||
categories['format'] = []
|
||||
for fmt in self.conn.get('SELECT DISTINCT format FROM data'):
|
||||
fmt = fmt[0]
|
||||
|
Loading…
x
Reference in New Issue
Block a user