RED-2973: Sort comments by date

This commit is contained in:
deiflaender 2021-12-07 11:22:41 +01:00
parent 11a7af57e4
commit cd71df40ab

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) {