Pull request #148: RED-2973: Sort comments by date

Merge in RED/persistence-service from RED-2973 to master

* commit 'cd71df40abec501025a2b12de8ed94e28db64c96':
  RED-2973: Sort comments by date
This commit is contained in:
Dominique Eiflaender 2021-12-07 11:26:22 +01:00
commit 95187c187a

View File

@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.time.OffsetDateTime;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -40,7 +41,7 @@ public class CommentPersistenceService {
public Map<String, List<CommentEntity>> findCommentsByFileID(String fileId, boolean includeDeletions) {
List<CommentEntity> comments = commentRepository.findByFileId(fileId, includeDeletions);
return comments.stream().collect(Collectors.groupingBy(CommentEntity::getAnnotationId));
return comments.stream().sorted(Comparator.comparing(CommentEntity::getDate)).collect(Collectors.groupingBy(CommentEntity::getAnnotationId));
}
public boolean fileHasComments(String fileId) {