Skip to content

Report owned books as complete on the Readarr API - #384

Merged
robertlordhood merged 1 commit into
developfrom
fix/readarr-api-owned-book-percent
Nov 27, 2026
Merged

robertlordhood merged 1 commit into
developfrom
fix/readarr-api-owned-book-percent

Conversation

@robertlordhood

@robertlordhood robertlordhood commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Readarr-compatible clients such as Seerr read statistics.percentOfBooks to decide whether a book is available. Chaptarr counted a book in that percentage only while it was monitored. A book that already had its files but was unmonitored reported 0% and showed as missing.

On the Readarr-compatible API, a book in the requested format now reports 100% when it has at least one file and 0% when it has none, whatever its monitoring. Native Chaptarr responses keep the existing calculation.

Database Migration

NO

How was this tested?

Native .NET 10 build on Linux.

  • New test facade_book_list_should_report_existing_files_independently_of_monitoring (BookControllerStatisticsBatchFixture) covers:
    • an unmonitored audiobook and an unmonitored ebook with files (100%);
    • the wrong format (0%);
    • a native request (0%);
    • files removed (0%).
  • It fails without the change (expected 100, was 0) and passes with it.
  • The PostgreSQL case runs when the PostgreSQL test database is configured.
  • Ran the BookController, Readarr facade and BookResource tests: 398 passed, 0 failed (the PostgreSQL cases skipped without a configured database).

Screenshots (UI changes only)

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Book lists now report file availability based on whether matching audiobook or ebook files exist, independently of monitoring status.
    • Availability updates correctly when files are deleted or the selected format does not match.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The API maps matching facade media types to book statistics that report file availability. The test fixture now supplies book and author services and checks availability and monitoring states across SQLite and PostgreSQL.

Changes: Facade Book Availability Reporting

Layer / File(s) Summary
Facade book availability reporting
src/Chaptarr.Api.V1/Books/BookStatisticsResource.cs, src/Chaptarr.Api.V1/Books/BookResource.cs, src/Chaptarr.Core.Test/Api/BookControllerStatisticsBatchFixture.cs
The statistics resource supports reporting availability from book file counts. Book resource mapping enables this mode when the facade and resource media types match. Tests check facade book-list statistics across media types, missing facade context, monitoring changes, and file deletions on SQLite and PostgreSQL.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 6af1d

Readarr-compatible responses now report a book with at least one file in the requested format as 100% complete regardless of monitoring, which fixes unmonitored owned books being treated as missing. Native responses keep their existing behavior. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: owned books are reported as complete on the Readarr-compatible API. The changeset sets statistics.percentOfBooks to 100 for a requested-format book with files, regardl…
Description check Passed The description covers the purpose and behavior change, the affected statistic, and the native-response exception. It says there is no database migration and gives a clear test plan with OS, runtime, …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: owned books are reported as complete on the Readarr-compatible API. The changeset sets statistics.percentOfBooks to 100 for a requested-format book with files, regardless of monitoring. The title is specific and matches the objectives.

Full details: Description check

Explanation

The description covers the purpose and behavior change, the affected statistic, and the native-response exception. It says there is no database migration and gives a clear test plan with OS, runtime, test name, results, and the skipped PostgreSQL cases. It follows the template's sections. The AI-disclosure note and review-time note are template boilerplate and do not need author content. The Fixes # line is absent, but it is conditional ('if applicable').

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8887aa8d-6f94-495e-a51a-d75a0317e3c4
Commits

Reviewing files that changed from the base of the PR and between 42a0e0b and 6af1d2f.

Files selected for processing: 3

  • src/Chaptarr.Api.V1/Books/BookResource.cs
  • src/Chaptarr.Api.V1/Books/BookStatisticsResource.cs
  • src/Chaptarr.Core.Test/Api/BookControllerStatisticsBatchFixture.cs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@robertlordhood
robertlordhood merged commit afbc67e into develop Nov 27, 2026
13 checks passed
@robertlordhood
robertlordhood deleted the fix/readarr-api-owned-book-percent branch November 27, 2026 18:42
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.

1 participant