From e1d1c35b5a31a022eb08c8673faab0fb937de564 Mon Sep 17 00:00:00 2001 From: Alex <25013571+alexhb1@users.noreply.github.com> Date: Fri, 18 Sep 2026 17:50:55 +0100 Subject: [PATCH] fix(api): exclude supplementary files from file type facet (#2688) --- .../booklore/app/specification/AppBookSpecification.java | 6 ++++-- .../java/org/booklore/service/browse/BookFacetService.java | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/org/booklore/app/specification/AppBookSpecification.java b/backend/src/main/java/org/booklore/app/specification/AppBookSpecification.java index 99a980922..9e8ca8d6e 100644 --- a/backend/src/main/java/org/booklore/app/specification/AppBookSpecification.java +++ b/backend/src/main/java/org/booklore/app/specification/AppBookSpecification.java @@ -271,7 +271,8 @@ public class AppBookSpecification { Subquery sub = query.subquery(Long.class); Root 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 sub = query.subquery(Long.class); Root 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)); diff --git a/backend/src/main/java/org/booklore/service/browse/BookFacetService.java b/backend/src/main/java/org/booklore/service/browse/BookFacetService.java index 2fe28c457..5c2aa3448 100644 --- a/backend/src/main/java/org/booklore/service/browse/BookFacetService.java +++ b/backend/src/main/java/org/booklore/service/browse/BookFacetService.java @@ -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 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")),