Skip to content

Commit

Permalink
fix(api): find book siblings by metadata.numberSort
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Mar 20, 2020
1 parent 0721f31 commit 1902e72
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ class BookController(
if (!principal.user.canAccessBook(book)) throw ResponseStatusException(HttpStatus.UNAUTHORIZED)

val previousBook = book.series.books
.sortedByDescending { it.number }
.find { it.number < book.number }
.sortedByDescending { it.metadata.numberSort }
.find { it.metadata.numberSort < book.metadata.numberSort }

previousBook?.toDto(includeFullUrl = principal.user.isAdmin())
?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
Expand All @@ -169,8 +169,8 @@ class BookController(
if (!principal.user.canAccessBook(book)) throw ResponseStatusException(HttpStatus.UNAUTHORIZED)

val nextBook = book.series.books
.sortedBy { it.number }
.find { it.number > book.number }
.sortedBy { it.metadata.numberSort }
.find { it.metadata.numberSort > book.metadata.numberSort }

nextBook?.toDto(includeFullUrl = principal.user.isAdmin()) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
Expand Down

0 comments on commit 1902e72

Please sign in to comment.