I don't understand the need for these two conditions.
(db.user_sub_chapter_progress.chapter_id == lastPageChapter ) & (db.user_sub_chapter_progress.sub_chapter_id == lastPageSubchapter)

If a user jumps to a new part of the book via the table of contents then their progress will stop getting updated.