Skip to content

Fix: percentOfBooks counts files instead of available books (multi-file audiobooks exceed 100%) - #93

Open
sebclark wants to merge 1 commit into
Chaptarr:developfrom
sebclark:fix-percent-of-books-file-count
Open

Fix: percentOfBooks counts files instead of available books (multi-file audiobooks exceed 100%)#93
sebclark wants to merge 1 commit into
Chaptarr:developfrom
sebclark:fix-percent-of-books-file-count

Conversation

@sebclark

Copy link
Copy Markdown
Contributor

Fixes #83

The bug

BookStatisticsResource.PercentOfBooks divides BookFileCount by BookCount, so a complete 24-file audiobook reports percentOfBooks: 2400. Verified live: an 11-file book returns 1100.

The core layer already computes the right numerator - BookStatistics.AvailableBookCount comes back from the statistics SQL - but the book resource neither maps it nor uses it. The author-level resource (AuthorStatisticsResource) already does this correctly with AvailableBookCount.

The fix

Map AvailableBookCount onto BookStatisticsResource and use it in PercentOfBooks, mirroring the author resource. Three lines.

Tests

New BookStatisticsResourceFixture: a complete 24-file/1-book model must report 100 (fails on current develop with 2400), and an empty book reports 0. Both pass with the fix; full Core.Test suite green (2854/2854).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant