Repository navigation
Xteink readers: CrossInk reading stats, a CrossPoint plugin, account import (experimental) - #325
Merged
Merged
Conversation
CrossInk 2.0 sends reading sessions, daily counters and totals next to KOSync progress. Tome now answers its stats probe and stores each sitting as a reading session, with a receipt of what the reader last reported so a trim or delete in Tome survives a re-send. Three new tables, no change to existing ones. Clippings answer 501 on purpose: a 404 would make the reader drop stats for the whole server. Also: per-book pace divides only by time from sessions with pages, the KOSync link endpoint checks book visibility, and the account export includes the new data.
…imental) A sideloaded file is only a hash to Tome, so its progress and uploaded reading sessions had no book. A reader that sends document metadata with its progress push (CrossInk: Send Document Metadata) now names the book: - one library book that is the same book: the document is linked to it - none: a book record without a file (status "no_file") is created, so the reading shows on Home, in the stats, the calendar and the session list - several: left to the manual link, which now shows the reader's title Matching is exact, never by similarity: same title and authors (any order), no disagreement about the volume, an ISBN only with the title or author agreeing, and never a title without an author. A file-less book is private to its owner and stays out of everything that lists or serves files, including duplicate detection. Linking the document to the real book hands over sessions, read status, finish date, rating and review, and removes the file-less record. Deleting one stops tracking that file. One new table (kosync_document_meta); no existing table changes.
…CrossPoint Sync import (experimental) Four additions on top of the stats sync and the file-less books: - Library: a user's own file-less books appear in the web Library and in library search with a "No file" badge (opt-in query parameter, so the iOS app, the KOReader plugin and OPDS keep getting books with files only), never go into a library, and get a "Missing: File" filter. - Clippings: the reader's saved passages sync both ways over its extended API (upload, cursor download, deletion markers, revisions that never go back) and show read-only on the Highlights page, the book page and the Home spotlight, in the viewer's time zone. Never sent to KOReader devices. - Per-book pages: the reader's lifetime snapshot per book is kept (kosync_book_stats) and fills a book's all-time Pages and Pace, and the all-time per-book table and pages total, with pace over the reader's own time. Nothing dated changes. - Import: Settings > Import reading history takes a CrossPoint Sync account export. Preview and import run the same code in a savepoint; the preview writes nothing and releases the lock. Sessions, statuses (Tome's own win), progress, clippings, per-book snapshots and daily counters come over through the same matching as the live sync. Idempotent, all or nothing, 20 MiB limit, tracker documents skipped. Two new tables (kosync_clippings, kosync_book_stats); no existing table changes. Verified with the firmware simulator on both firmware versions, a Docker round trip 3.0.0 -> branch -> 3.0.0 and the full suite.
…tal) The reader's per-book page counter only grows and is sent whenever it changed, so its growth between two snapshots is exactly the pages turned in between. That growth is now shared out over the reader's sessions received between the two snapshots, by reading time, and written onto them as attributed pages (reading_sessions.pages_attributed, added by an idempotent startup migration; v3.0.0 still reads and writes such rows). Windows use the time Tome received each session, not the reader's clock. Growth that arrives before its sessions waits for the next snapshot and is then split over all of them; every window is closed, a lower counter starts a new base and takes nothing back, and a sitting that spans a sync takes its share of the next growth. reader_pages returns only the part of a counter no existing session carries, so a book's all-time pages equal the reader's counter, also after a trim, a delete or a re-send; trimmed sessions keep the reader's pace. Imported history stays time only. Daily charts, the calendar, session rows, page goals and pace per session now include CrossInk reading; the session log shows pages for every source, with a mark on attributed ones.
Every KOSync progress push has been logged in reading_history since the feature existed, but nothing read it for stats. The book page's progress line now takes the furthest position of each reading day from those pushes and merges it with the per-session progress by max, so books read on a CrossInk reader get the line; a push on a day without reading carries forward to the next reading day. Pushes logged before the document was linked to a book follow the link (attach_history at every link site; the CrossPoint Sync import links them all in one statement). A composite index on reading_history (user_id, book_id) is added by an idempotent startup migration.
…imental) The Pages total of a series' reading stats summed session pages only, so a series read on a CrossInk reader showed the attributed part and missed the counter's rest. It now adds the per-book reader pages past what sessions carry, and a counter-attributed session that imported KOReader page-stats supersede adds nothing, so the counter is counted exactly once.
…position log On a book with KOReader page-stats the line only used sessions that still counted for time, which dropped every plugin sitting the page-stats covered, the only rows carrying progress_end. A Kindle book got a line from the few uncovered sittings (ending at 63% on a finished book) or none at all. Every session's position counts now; position_history merges in per day the way reading_history does for KOSync pushes, with the rows before a restore that lie above the restored position left out. Verified on a copy of the prod database: 9 more books get a line, 11 finished books now end at 100%, no other field changed.
…rimental) A book Tome only knows from a KOSync reader, without a file, can be read on a TomeSync plugin device too. The plugin's reading routes (position, session, rating, status, highlights) accept the user's own book without a file. The plugin's lookup follows the reader's document link by content id or by the MD5 of the file name, then falls back to the title in the file name; a link that was only a guess (new nullable column kosync_document_map.guessed) is never followed. For such a book the reader's position is served to the plugin without TOME_KOSYNC_POSITION_BRIDGE, and a locator that only names the chapter is dropped so the plugin jumps by percentage.
…first sync, the reader's finished flag (experimental) The reader's lifetime snapshot holds totals and a calendar of read days from before it first synced to Tome. The days now count for streaks and are marked on the Calendar; the Stats page set to All includes the earlier time, sessions and pages. The first page counter of a book that is new to the reader and to Tome is given to the sessions sent with it, also for a base stored earlier, at the book's next sync. A book the reader reports as finished is marked as read.
… own Settings section, docs guide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes for users
Everything here is marked experimental.
How a reader is connected (plugin)
The reader asks Tome for a code and shows it with a QR code. The signed-in user confirms the code on
/link-reader. The reader then collects a key of its own, listed under Settings > Access as "CrossPoint reader" and revocable there. A reader key opens only the reader's routes; KOReader plugin keys do not open them, and reader keys do not open the TomeSync routes.API
All under
/api:/api/v1/api/v1/stats/{summary,global,sessions,books}and/clippings/{document}(the firmware adds its own/api/v1to the KOSync address)./api/v1/crosspoint/device/code,device/token,device/{code},device/approve,sessions,catalog,status,plugin.zip.GET /api/bookstakesinclude_no_file(off by default).Changes that reach KOReader plugin users
backend/api/tome_sync.pychanges in three ways:resolvecan return the book a KOSync reader linked the same file to.GET positionleaves out a locator that only names a chapter start, so the plugin goes by percentage.Schema change and upgrade
Additive only. New tables are created at startup. Guarded
ALTER TABLEs addapi_keys.kind,reading_sessions.pages_attributed,kosync_document_map.guessedand columns on the reader stats tables; each step checks first. An older version ignores all of it: going from the tester's image to this one and back was run on one data volume.Tested
pytest tests/ -q: 2,304 passed on this branch merged with v3.1.0 (three telemetry tests need the telemetry switch at its default; they pass then)npm run buildpasses, message catalogs re-extracted, docs site buildsKnown limits