mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
7b43756258
Sorting by "Last Read" ordered on reading_progress.updated_at, but the KOReader sync path deliberately freezes that column so it stays a reliable "last local write" marker when resolving conflicts against device progress. Readers who sync from KOReader therefore kept the timestamp of their first ever sync of each book forever, so the smart scope sort, the jump-bucket rails and the dashboard Continue Reading list all looked unordered. Add reading_progress.last_read_at, which advances on every write unless a path opts out, and move every "last read" reader onto it. Leave updated_at to the conflict-resolution and progress-resume paths that genuinely mean "last local write". Kobo bookmark-location stamping opts out because recording which Location a bookmark maps to is bookkeeping rather than reading, while the Kobo progress write and the migration importer pass their source timestamps through so imported history is not stamped as read today. Move the ebook-versus-audiobook recency tiebreaks onto the new column as well. They compared a frozen timestamp against a live one, which selected the wrong percentage for the same reason. Swap the (user_id, updated_at) index for (user_id, last_read_at), since the ordering consumer that justified it moved. Backfill last_read_at from updated_at in the migration, as the generated DEFAULT now() would otherwise make every existing book look as though it had just been read. Fixes #1013