mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement restrict_to_book_ids for annotation fetching
This commit is contained in:
parent
dc13fdcde0
commit
0f4b491083
@ -1805,6 +1805,8 @@ class DB(object):
|
|||||||
ls = json.loads
|
ls = json.loads
|
||||||
try:
|
try:
|
||||||
for (rowid, book_id, fmt, user_type, user, annot_data, text) in self.execute(query, tuple(data)):
|
for (rowid, book_id, fmt, user_type, user, annot_data, text) in self.execute(query, tuple(data)):
|
||||||
|
if restrict_to_book_ids is not None and book_id not in restrict_to_book_ids:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
parsed_annot = ls(annot_data)
|
parsed_annot = ls(annot_data)
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -1875,7 +1877,7 @@ class DB(object):
|
|||||||
self.execute('UPDATE annotations SET annot_data=?, timestamp=?, annot_type=?, searchable_text=?, annot_id=? WHERE id=?',
|
self.execute('UPDATE annotations SET annot_data=?, timestamp=?, annot_type=?, searchable_text=?, annot_id=? WHERE id=?',
|
||||||
(json.dumps(annot), timestamp, atype, text, aid, annot_id))
|
(json.dumps(annot), timestamp, atype, text, aid, annot_id))
|
||||||
|
|
||||||
def all_annotations(self, restrict_to_user=None, limit=None, annotation_type=None, ignore_removed=False):
|
def all_annotations(self, restrict_to_user=None, limit=None, annotation_type=None, ignore_removed=False, restrict_to_book_ids=None):
|
||||||
ls = json.loads
|
ls = json.loads
|
||||||
q = 'SELECT id, book, format, user_type, user, annot_data FROM annotations'
|
q = 'SELECT id, book, format, user_type, user, annot_data FROM annotations'
|
||||||
data = []
|
data = []
|
||||||
@ -1891,6 +1893,8 @@ class DB(object):
|
|||||||
q += ' ORDER BY timestamp DESC '
|
q += ' ORDER BY timestamp DESC '
|
||||||
count = 0
|
count = 0
|
||||||
for (rowid, book_id, fmt, user_type, user, annot_data) in self.execute(q, tuple(data)):
|
for (rowid, book_id, fmt, user_type, user, annot_data) in self.execute(q, tuple(data)):
|
||||||
|
if restrict_to_book_ids is not None and book_id not in restrict_to_book_ids:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
annot = ls(annot_data)
|
annot = ls(annot_data)
|
||||||
atype = annot['type']
|
atype = annot['type']
|
||||||
|
@ -2320,8 +2320,8 @@ class Cache(object):
|
|||||||
return tuple(self.backend.all_annotation_types())
|
return tuple(self.backend.all_annotation_types())
|
||||||
|
|
||||||
@read_api
|
@read_api
|
||||||
def all_annotations(self, restrict_to_user=None, limit=None, annotation_type=None, ignore_removed=False):
|
def all_annotations(self, restrict_to_user=None, limit=None, annotation_type=None, ignore_removed=False, restrict_to_book_ids=None):
|
||||||
return tuple(self.backend.all_annotations(restrict_to_user, limit, annotation_type, ignore_removed))
|
return tuple(self.backend.all_annotations(restrict_to_user, limit, annotation_type, ignore_removed, restrict_to_book_ids))
|
||||||
|
|
||||||
@read_api
|
@read_api
|
||||||
def search_annotations(
|
def search_annotations(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user