Skip to content

feat: add GET /api/v1/stats/overview for readers - #39

Merged
itsthisjustin merged 1 commit into
crosspoint-reader:mainfrom
eszter007:feat/stats-overview
Oct 24, 2026
Merged

itsthisjustin merged 1 commit into
crosspoint-reader:mainfrom
eszter007:feat/stats-overview

Conversation

@eszter007

@eszter007 eszter007 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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/summary and /stats/activity. Both are too big for a device with about 380 KB of RAM: activity lists every book and day, and summary carries 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:

  • the counts: books finished, finished this year, pages read
  • the streaks: current and longest
  • reading days: how many in total, plus a bitmap of the last days days
  • reading time from device stats: total, sessions, today, and the last 7 days

Size. 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: days defaults 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.js builds. 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's finished_at, like the Stats page.

No logic copied. The /stats/summary and /stats/activity handler bodies moved into summaryFor / activityFor, so the new endpoint reuses them. Both existing endpoints return what they did before.

test/stats-overview.test.ts covers four sources:

  • syncs from another app on two days
  • device minutes on two days
  • one book finished last year and one this year
  • the days window, the default and the cap

The full suite passes (687 tests), and so does tsc --noEmit. API docs are updated.

…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.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f7762f9b-22f4-474b-8b3e-e2f1a7e1f676
Commits

Reviewing files that changed from the base of the PR and between 45d4910 and 22e300c.

Files selected for processing: 3
  • docs/API.md
  • src/routes/v1/stats.ts
  • test/stats-overview.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-24T17:39:30.736279Z
We couldn’t complete this review. Comment @codex review to try again.
22e300c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@eszter007 eszter007 changed the title Add GET /api/v1/stats/overview for readers feat: add GET /api/v1/stats/overview for readers Oct 24, 2026
@itsthisjustin
itsthisjustin merged commit b25095a into crosspoint-reader:main Oct 24, 2026
1 check passed
@eszter007
eszter007 deleted the feat/stats-overview branch October 24, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants