feat(document): add DocumentSort.UPDATED_AT for reader dashboard feed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -727,6 +727,7 @@ public class DocumentService {
|
|||||||
return switch (sort) {
|
return switch (sort) {
|
||||||
case TITLE -> Sort.by(direction, "title");
|
case TITLE -> Sort.by(direction, "title");
|
||||||
case UPLOAD_DATE -> Sort.by(direction, "createdAt");
|
case UPLOAD_DATE -> Sort.by(direction, "createdAt");
|
||||||
|
case UPDATED_AT -> Sort.by(direction, "updatedAt");
|
||||||
default -> Sort.by(direction, "documentDate");
|
default -> Sort.by(direction, "documentDate");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package org.raddatz.familienarchiv.document;
|
package org.raddatz.familienarchiv.document;
|
||||||
|
|
||||||
public enum DocumentSort {
|
public enum DocumentSort {
|
||||||
DATE, TITLE, SENDER, RECEIVER, UPLOAD_DATE, RELEVANCE
|
DATE, TITLE, SENDER, RECEIVER, UPLOAD_DATE, UPDATED_AT, RELEVANCE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
CREATE INDEX IF NOT EXISTS idx_documents_updated_at ON documents(updated_at DESC);
|
||||||
@@ -1403,6 +1403,21 @@ class DocumentServiceTest {
|
|||||||
assertThat(result.items()).hasSize(1); // only the slice is enriched
|
assertThat(result.items()).hasSize(1); // only the slice is enriched
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void searchDocuments_UPDATED_AT_sort_resolves_to_updatedAt_field() {
|
||||||
|
ArgumentCaptor<Pageable> captor = ArgumentCaptor.forClass(Pageable.class);
|
||||||
|
when(documentRepository.findAll(any(org.springframework.data.jpa.domain.Specification.class), any(Pageable.class)))
|
||||||
|
.thenReturn(new PageImpl<>(List.of()));
|
||||||
|
|
||||||
|
documentService.searchDocuments(null, null, null, null, null, null, null, null,
|
||||||
|
DocumentSort.UPDATED_AT, "DESC", null,
|
||||||
|
org.springframework.data.domain.PageRequest.of(0, 5));
|
||||||
|
|
||||||
|
verify(documentRepository).findAll(any(org.springframework.data.jpa.domain.Specification.class), captor.capture());
|
||||||
|
assertThat(captor.getValue().getSort())
|
||||||
|
.isEqualTo(Sort.by(Sort.Direction.DESC, "updatedAt"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void searchDocuments_senderSort_slicesInMemoryAndReportsFullTotal() {
|
void searchDocuments_senderSort_slicesInMemoryAndReportsFullTotal() {
|
||||||
// Fixture: 120 docs with senders; request page 1, size 50 → expect 50 items
|
// Fixture: 120 docs with senders; request page 1, size 50 → expect 50 items
|
||||||
|
|||||||
Reference in New Issue
Block a user