fix(api): exclude supplementary files from file type facet (#2688)

This commit is contained in:
Alex
2026-09-18 17:50:55 +01:00
committed by GitHub
parent f0ca4e57b0
commit e1d1c35b5a
2 changed files with 9 additions and 3 deletions
@@ -271,7 +271,8 @@ public class AppBookSpecification {
Subquery<Long> sub = query.subquery(Long.class);
Root<BookFileEntity> bfRoot = sub.from(BookFileEntity.class);
sub.select(bfRoot.get("book").get("id"))
.where(cb.equal(bfRoot.get("bookType"), ft));
.where(cb.equal(bfRoot.get("bookType"), ft),
cb.isTrue(bfRoot.get("isBookFormat")));
predicates.add(root.get("id").in(sub));
}
return cb.and(predicates.toArray(Predicate[]::new));
@@ -280,7 +281,8 @@ public class AppBookSpecification {
Subquery<Long> sub = query.subquery(Long.class);
Root<BookFileEntity> bfRoot = sub.from(BookFileEntity.class);
sub.select(bfRoot.get("book").get("id"))
.where(bfRoot.get("bookType").in(parsed));
.where(bfRoot.get("bookType").in(parsed),
cb.isTrue(bfRoot.get("isBookFormat")));
if ("not".equals(mode)) {
return cb.not(root.get("id").in(sub));
@@ -55,7 +55,11 @@ public class BookFacetService {
new FacetDef("publisher", "Publisher", (cb, root, userId) -> metadata(root).get("publisher")),
new FacetDef("language", "Language", (cb, root, userId) -> metadata(root).get("language")),
new FacetDef("narrator", "Narrator", (cb, root, userId) -> metadata(root).get("narrator")),
new FacetDef("file_type", "File Type", (cb, root, userId) -> root.join("bookFiles", JoinType.LEFT).get("bookType")),
new FacetDef("file_type", "File Type", (cb, root, userId) -> {
Join<BookEntity, BookFileEntity> files = root.join("bookFiles", JoinType.LEFT);
files.on(cb.isTrue(files.get("isBookFormat")));
return files.get("bookType");
}),
new FacetDef("content_rating", "Content Rating", (cb, root, userId) -> metadata(root).get("contentRating")),
new FacetDef("amazon_rating", "Amazon Rating", (cb, root, userId) -> metadata(root).get("amazonRating")),
new FacetDef("goodreads_rating", "Goodreads Rating", (cb, root, userId) -> metadata(root).get("goodreadsRating")),