Skip to content

Commit

Permalink
release: 1.0.3 (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored Dec 25, 2024
2 parents 053dd41 + 4d47192 commit e5bbe7f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ interface GuildRepository : JpaRepository<Guild, Long> {
nativeQuery = true,
)
fun search(@Param("text") text: String, pageable: Pageable): Page<Guild>

@Query(value = "select g from Guild as g")
fun search(pageable: Pageable): Page<Guild>
}
13 changes: 8 additions & 5 deletions src/main/kotlin/org/gitanimals/guild/domain/GuildService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ class GuildService(
}

fun search(text: String, pageNumber: Int, filter: SearchFilter): Page<Guild> {
return guildRepository.search(text, Pageable.ofSize(PAGE_SIZE).withPage(pageNumber))
.onEach {
loadMembers.invoke(it)
loadWaitMembers.invoke(it)
}
return if (text.isBlank()) {
guildRepository.search(Pageable.ofSize(PAGE_SIZE).withPage(pageNumber))
} else {
guildRepository.search(text, Pageable.ofSize(PAGE_SIZE).withPage(pageNumber))
}.onEach {
loadMembers.invoke(it)
loadWaitMembers.invoke(it)
}
}

fun findAllWithLimit(limit: Int): List<Guild> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class InMemoryRandomGuildCache(
response.add(filteredGuilds[idx])
}

return PageImpl(filter.sort(response), Pageable.ofSize(pageNumber), guilds.size.toLong())
return PageImpl(filter.sort(response), Pageable.ofSize(PAGE_SIZE), guilds.size.toLong())
}

@Scheduled(cron = ONCE_0AM_TIME)
Expand Down

0 comments on commit e5bbe7f

Please sign in to comment.