mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 09:03:07 +02:00
Speed up annotations_count_for_book
No need to use a transaction for a single readonly operation
This commit is contained in:
parent
3e53b5129b
commit
49e70ff532
1 changed files with 3 additions and 4 deletions
|
|
@ -1949,10 +1949,9 @@ def dirty_books_with_dirtied_annotations(self):
|
|||
return changed
|
||||
|
||||
def annotation_count_for_book(self, book_id):
|
||||
with self.conn:
|
||||
c = self.execute('SELECT count(id) FROM annotations WHERE book=?', (book_id,))
|
||||
r = c.fetchone()[0]
|
||||
return r
|
||||
for (count,) in self.execute('SELECT count(id) FROM annotations WHERE book=?', (book_id,)):
|
||||
return count
|
||||
return 0
|
||||
|
||||
def conversion_options(self, book_id, fmt):
|
||||
for (data,) in self.conn.get('SELECT data FROM conversion_options WHERE book=? AND format=?', (book_id, fmt.upper())):
|
||||
|
|
|
|||
Loading…
Reference in a new issue