Sync reading state only for books on kobo shelves
This commit is contained in:
parent
6014b04b2a
commit
24bbf226a1
33
cps/kobo.py
33
cps/kobo.py
|
@ -171,7 +171,7 @@ def HandleSyncRequest():
|
||||||
ub.BookShelf.date_added > sync_token.books_last_modified))
|
ub.BookShelf.date_added > sync_token.books_last_modified))
|
||||||
.filter(db.Data.format.in_(KOBO_FORMATS))
|
.filter(db.Data.format.in_(KOBO_FORMATS))
|
||||||
.order_by(db.Books.id)
|
.order_by(db.Books.id)
|
||||||
.order_by('last_modified')
|
.order_by(ub.ArchivedBook.last_modified)
|
||||||
.join(ub.BookShelf, db.Books.id == ub.BookShelf.book_id)
|
.join(ub.BookShelf, db.Books.id == ub.BookShelf.book_id)
|
||||||
.join(ub.Shelf)
|
.join(ub.Shelf)
|
||||||
.filter(ub.Shelf.kobo_sync)
|
.filter(ub.Shelf.kobo_sync)
|
||||||
|
@ -253,11 +253,36 @@ def HandleSyncRequest():
|
||||||
books_last_id = -1
|
books_last_id = -1
|
||||||
|
|
||||||
# generate reading state data
|
# generate reading state data
|
||||||
|
changed_reading_states = ub.session.query(ub.KoboReadingState)
|
||||||
|
|
||||||
|
if only_kobo_shelves:
|
||||||
changed_reading_states = (
|
changed_reading_states = (
|
||||||
ub.session.query(ub.KoboReadingState)
|
changed_reading_states.join(ub.BookShelf, ub.KoboReadingState.book_id == ub.BookShelf.book_id)
|
||||||
.filter(and_(func.datetime(ub.KoboReadingState.last_modified) > sync_token.reading_state_last_modified,
|
.join(ub.Shelf)
|
||||||
|
.filter(
|
||||||
|
ub.Shelf.kobo_sync,
|
||||||
|
or_(
|
||||||
|
func.datetime(ub.KoboReadingState.last_modified) > sync_token.reading_state_last_modified,
|
||||||
|
ub.BookShelf.date_added > sync_token.books_last_modified
|
||||||
|
)
|
||||||
|
)
|
||||||
|
).distinct()
|
||||||
|
|
||||||
|
else:
|
||||||
|
changed_reading_states = (
|
||||||
|
changed_reading_states.filter(
|
||||||
|
func.datetime(ub.KoboReadingState.last_modified) > sync_token.reading_state_last_modified
|
||||||
|
)
|
||||||
|
)
|
||||||
|
changed_reading_states = (
|
||||||
|
changed_reading_states.filter(
|
||||||
|
and_(
|
||||||
ub.KoboReadingState.user_id == current_user.id,
|
ub.KoboReadingState.user_id == current_user.id,
|
||||||
ub.KoboReadingState.book_id.notin_(reading_states_in_new_entitlements))))
|
ub.KoboReadingState.book_id.notin_(reading_states_in_new_entitlements)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
for kobo_reading_state in changed_reading_states.all():
|
for kobo_reading_state in changed_reading_states.all():
|
||||||
book = calibre_db.session.query(db.Books).filter(db.Books.id == kobo_reading_state.book_id).one_or_none()
|
book = calibre_db.session.query(db.Books).filter(db.Books.id == kobo_reading_state.book_id).one_or_none()
|
||||||
if book:
|
if book:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user