feat(search): extended search, sort options, live tag filter, result count #183

Merged
marcel merged 26 commits from feat/issue-180-extended-search-sort into main 2026-04-06 19:18:12 +02:00
2 changed files with 8 additions and 0 deletions
Showing only changes of commit 110024245d - Show all commits

View File

@@ -5,6 +5,11 @@ import org.raddatz.familienarchiv.model.Document;
import java.util.List;
public record DocumentSearchResult(List<Document> documents, long total) {
/**
* Creates a result where total equals the list size.
* No pagination yet — the full matched set is always returned.
* When pagination is added, total must come from a DB COUNT query, not list.size().
*/
public static DocumentSearchResult of(List<Document> documents) {
return new DocumentSearchResult(documents, documents.size());
}

View File

@@ -292,6 +292,9 @@ public class DocumentService {
.and(hasTagPartial(tagQ))
.and(hasStatus(status));
// SENDER and RECEIVER are sorted in-memory because JPA's Sort.by("sender.lastName")
// generates an INNER JOIN that silently drops documents with null sender/receivers.
// TODO: replace with a native @Query using ORDER BY ... NULLS LAST when pagination is added.
if (sort == DocumentSort.RECEIVER) {
List<Document> results = documentRepository.findAll(spec);
return sortByFirstReceiver(results, dir);