Skip to content

Commit faaa865

Browse files
author
chedim
committed
Removes PageRequest from one of Profile methods
1 parent 5df6c09 commit faaa865

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/trycb/controller/ProfileController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ public ResponseEntity<List<Profile>> listProfiles(
3434
@RequestParam(defaultValue = "0") int page
3535
) {
3636
if (pageSize < 1 || pageSize > 10) pageSize = 10;
37-
PageRequest pageRequest = PageRequest.of(page, pageSize);
3837
List<Profile> result;
3938

4039
if (query == null || query.length() != 0) {
40+
PageRequest pageRequest = PageRequest.of(page, pageSize);
4141
result = profileRepository.findAll(pageRequest).toList();
4242
} else {
4343
// This is just a LIKE query.
4444
// For full-text search documentation refer to:
4545
// https://docs.couchbase.com/java-sdk/current/howtos/full-text-searching-with-sdk.html
46-
result = profileRepository.findByText(query, pageRequest).toList();
46+
result = profileRepository.findByText(query, pageRequest, page, pageSize).toList();
4747
}
4848

4949
if (result != null && result.size() > 0) {

src/main/java/trycb/repository/ProfileRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
@Repository
1515
public interface ProfileRepository extends PagingAndSortingRepository<Profile, UUID> {
16-
@Query("#{#n1ql.selectEntity} WHERE firstName LIKE '%' || $1 || '%' OR lastName LIKE '%' || $1 || '%' OR address LIKE '%' || $1 || '%'")
17-
Page<Profile> findByText(String query, Pageable pageable);
16+
@Query("#{#n1ql.selectEntity} WHERE firstName LIKE '%' || $1 || '%' OR lastName LIKE '%' || $1 || '%' OR address LIKE '%' || $1 || '%' OFFSET $2 * $3 LIMIT $3")
17+
List<Profile> findByText(String query, int pageNum, int pageSize);
1818

1919
Page<Profile> findByAge(byte age, Pageable pageable);
2020
}

0 commit comments

Comments
 (0)