Skip to content

Commit

Permalink
Fix: Handle for empty keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
huGgW committed Apr 6, 2024
1 parent 432bc4f commit d046ad5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ class NewsRepositoryImpl(
.limit(pageRequest.pageSize.toLong())
.distinct()

val newsEntityList = when (sortBy) {
ContentSearchSortType.DATE -> newsEntityQuery.orderBy(newsEntity.createdAt.desc())
ContentSearchSortType.RELEVANCE -> newsEntityQuery
val newsEntityList = when {
sortBy == ContentSearchSortType.DATE || keyword.isNullOrEmpty() -> newsEntityQuery.orderBy(
newsEntity.createdAt.desc()
)
else /* sortBy == RELEVANCE */ -> newsEntityQuery
}.fetch()

val newsSearchDtoList: List<NewsSearchDto> = newsEntityList.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ class SeminarRepositoryImpl(
.offset(pageRequest.offset)
.limit(pageRequest.pageSize.toLong())

val seminarEntityList = when (sortBy) {
ContentSearchSortType.DATE -> seminarEntityQuery.orderBy(seminarEntity.createdAt.desc())
ContentSearchSortType.RELEVANCE -> seminarEntityQuery
val seminarEntityList = when {
sortBy == ContentSearchSortType.DATE || keyword.isNullOrEmpty() -> seminarEntityQuery.orderBy(
seminarEntity.createdAt.desc()
)
else /* sortBy == RELEVANCE */ -> seminarEntityQuery
}.fetch()

val seminarSearchDtoList: MutableList<SeminarSearchDto> = mutableListOf()
Expand Down

0 comments on commit d046ad5

Please sign in to comment.