Skip to content

Count books by library only if they have book files; add repository test#3

Merged
dinosmm merged 1 commit into
dmsfrom
codex/investigate-book-count-discrepancy
Apr 24, 2026
Merged

Count books by library only if they have book files; add repository test#3
dinosmm merged 1 commit into
dmsfrom
codex/investigate-book-count-discrepancy

Conversation

@dinosmm

@dinosmm dinosmm commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Ensure countByLibraryId reports the number of books in a library that actually have book files (and are not deleted), aligning it with the behavior of other book-type counting queries.

Description

  • Replace the previous simple count JPQL for countByLibraryId with a query that JOINs b.bookFiles bf, filters on bf.isBookFormat = true, and uses COUNT(DISTINCT b) to only count books that have book files and are not deleted.
  • Add countByLibraryId_countsOnlyBooksWithBookFiles to BookRepositoryDataJpaTest which persists a library, a file-backed book, a fileless book, and a deleted file-backed book, then asserts that bookRepository.countByLibraryId(...) returns 1.

Testing

  • Ran the repository data JPA tests (BookRepositoryDataJpaTest) which include the new countByLibraryId_countsOnlyBooksWithBookFiles test, and they passed.

Codex Task

@dinosmm dinosmm merged commit d634815 into dms Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant