Repository navigation
feat: add GET /api/v1/stats/overview for readers - #39
Conversation
…red bytes Counts and streaks over all history and every source; the reading-day bitmap is windowed by ?days= (default 365, max 3650) so readers can fetch it cheaply.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 30 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
I'd like to enable the firmware to show my whole reading picture on its stats screen: books finished, reading days and streaks. The Stats page computes all of that in the app from
/stats/summaryand/stats/activity. Both are too big for a device with about 380 KB of RAM:activitylists every book and day, andsummarycarries every day's minutes.This adds
GET /api/v1/stats/overview?tz=&days=. It returns the same numbers as the Stats page, in a few hundred bytes:daysdaysSize. Everything but the bitmap is a single number, computed over the whole history. The bitmap is the only part that grows, so it's windowed:
daysdefaults to 365 (46 bytes) and is capped at 3650. A reader asks for the window its screen shows.Same numbers as the app. Reading days are the union of three things: the device stats bitmap, the days with device minutes, and the activity's reading days (syncs and chosen start and finish dates). That's the same union
readingHistory.jsbuilds. Today counts toward the streak once read, and until then the streak runs to yesterday, also as in the app. Finished counts come from the activity'sfinished_at, like the Stats page.No logic copied. The
/stats/summaryand/stats/activityhandler bodies moved intosummaryFor/activityFor, so the new endpoint reuses them. Both existing endpoints return what they did before.test/stats-overview.test.tscovers four sources:dayswindow, the default and the capThe full suite passes (687 tests), and so does
tsc --noEmit. API docs are updated.