Fix: percentOfBooks counts files instead of available books (multi-file audiobooks exceed 100%) - #93
Open
sebclark wants to merge 1 commit into
Open
Conversation
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.
Fixes #83
The bug
BookStatisticsResource.PercentOfBooksdividesBookFileCountbyBookCount, so a complete 24-file audiobook reportspercentOfBooks: 2400. Verified live: an 11-file book returns1100.The core layer already computes the right numerator -
BookStatistics.AvailableBookCountcomes back from the statistics SQL - but the book resource neither maps it nor uses it. The author-level resource (AuthorStatisticsResource) already does this correctly withAvailableBookCount.The fix
Map
AvailableBookCountontoBookStatisticsResourceand use it inPercentOfBooks, mirroring the author resource. Three lines.Tests
New
BookStatisticsResourceFixture: a complete 24-file/1-book model must report100(fails on current develop with2400), and an empty book reports0. Both pass with the fix; full Core.Test suite green (2854/2854).