Skip to content
Snippets Groups Projects
Commit 516345ec authored by Alexandre Grison's avatar Alexandre Grison
Browse files

Returns comments sorted by latest first

parent 06759d63
Branches
No related tags found
No related merge requests found
......@@ -8,4 +8,5 @@ import org.springframework.stereotype.Repository
@Repository
interface CommentRepository : CrudRepository<Comment, Long> {
fun findByArticle(article: Article): List<Comment>
fun findByArticleOrderByCreatedAtDesc(article: Article): List<Comment>
}
\ No newline at end of file
......@@ -164,7 +164,7 @@ class ArticleHandler(val repository: ArticleRepository,
fun articleComments(@PathVariable slug: String): Any {
repository.findBySlug(slug)?.let {
val currentUser = userService.currentUser()
return commentsView(commentRepository.findByArticle(it), currentUser)
return commentsView(commentRepository.findByArticleOrderByCreatedAtDesc(it), currentUser)
}
throw NotFoundException()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment