mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Bug #1999571: Similar books: Grouped search problems.
Fixed by adding a new API method db.cache,split_if_is_multiple_composite(). This method converts the value to a list if the composite is "tags-like". The intention is that plugins etc can use the method if needed.
This commit is contained in:
parent
6be22faa78
commit
d3d125aa9a
@ -2349,6 +2349,13 @@ class Cache:
|
||||
return f.get_books_for_val(item_id_or_composite_value, self._get_proxy_metadata, self._all_book_ids())
|
||||
return self._books_for_field(f.name, int(item_id_or_composite_value))
|
||||
|
||||
@read_api
|
||||
def split_if_is_multiple_composite(self, f, v):
|
||||
fm = self.field_metadata.get(f, None)
|
||||
if fm and fm['datatype'] == 'composite' and fm['is_multiple']:
|
||||
return [v.strip() for v in v.split(',') if v.strip()]
|
||||
return v
|
||||
|
||||
@read_api
|
||||
def data_for_find_identical_books(self):
|
||||
''' Return data that can be used to implement
|
||||
|
@ -66,6 +66,7 @@ class SimilarBooksAction(InterfaceAction):
|
||||
v = mi.get(f, None)
|
||||
if not v:
|
||||
continue
|
||||
v = db.new_api.split_if_is_multiple_composite(f, v)
|
||||
if isinstance(v, list):
|
||||
val.update(v)
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user