feat(api): allow readlist custom sorting

This commit is contained in:
Gauthier Roebroeck 2022-07-28 09:34:07 +08:00
parent cc5ced63be
commit b9e69a1c9a
2 changed files with 3 additions and 0 deletions

View file

@ -37,6 +37,8 @@ class ReadListDao(
private val sorts = mapOf(
"name" to rl.NAME.collate(SqliteUdfDataSource.collationUnicode3),
"createdDate" to rl.CREATED_DATE,
"lastModifiedDate" to rl.LAST_MODIFIED_DATE,
)
override fun findByIdOrNull(readListId: String, filterOnLibraryIds: Collection<String>?, restrictions: ContentRestrictions): ReadList? =

View file

@ -103,6 +103,7 @@ class ReadListController(
@Parameter(hidden = true) page: Pageable,
): Page<ReadListDto> {
val sort = when {
page.sort.isSorted -> page.sort
!searchTerm.isNullOrBlank() -> Sort.by("relevance")
else -> Sort.by(Sort.Order.asc("name"))
}