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

This commit is contained in:
maverickstuder 2024-01-24 12:06:53 +01:00
parent 42b410f6f7
commit 6321295d02
2 changed files with 4 additions and 4 deletions

View File

@ -80,10 +80,7 @@ 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());
return commentRepository.findByFileIdAndAnnotationIdOrderByDate(fileId, annotationId, includeDeletions);
}

View File

@ -15,6 +15,9 @@ public interface CommentRepository extends JpaRepository<CommentEntity, Long> {
@Query("select e from CommentEntity e where e.fileId = :fileId and e.annotationId = :annotationId and (:includeDeletions = true or e.softDeletedTime is null)")
List<CommentEntity> findByFileIdAndAnnotationId(@Param("fileId") String fileId, @Param("annotationId") String annotationId, @Param("includeDeletions") boolean includeDeletions);
@Query("select e from CommentEntity e where e.fileId = :fileId and e.annotationId = :annotationId and (:includeDeletions = true or e.softDeletedTime is null) ORDER BY e.date")
List<CommentEntity> findByFileIdAndAnnotationIdOrderByDate(@Param("fileId") String fileId, @Param("annotationId") String annotationId, @Param("includeDeletions") boolean includeDeletions);
@Query("select e from CommentEntity e where e.fileId = :fileId and (:includeDeletions = true or e.softDeletedTime is null)")
List<CommentEntity> findByFileId(@Param("fileId") String fileId, @Param("includeDeletions") boolean includeDeletions);