RED-8248: Sent comments are not sorted by order of arrival

* added sorting for getComments called from controller
This commit is contained in:
maverickstuder 2024-01-24 10:32:17 +01:00
parent 06ea42c410
commit 42b410f6f7
2 changed files with 10 additions and 1 deletions

View File

@ -108,7 +108,7 @@ public class CommentService {
public List<Comment> getComments(String fileId, String annotationId) {
return toCommentList(commentPersistenceService.findCommentsByAnnotationId(fileId, annotationId, false));
return toCommentList(commentPersistenceService.findCommentsByAnnotationIdSortByDate(fileId, annotationId, false));
}

View File

@ -78,6 +78,15 @@ public class CommentPersistenceService {
}
public List<CommentEntity> findCommentsByAnnotationIdSortByDate(String fileId, String annotationId, boolean includeDeletions) {
return commentRepository.findByFileIdAndAnnotationId(fileId, annotationId, includeDeletions)
.stream()
.sorted(Comparator.comparing(CommentEntity::getDate))
.collect(Collectors.toList());
}
@Transactional
public void softDelete(long commentId, OffsetDateTime softDeletedTime) {