Skip to content

Commit 2e884ed

Browse files
authored
Fix/#23 (#140)
* fix to origin version * fix to random version
1 parent 7606754 commit 2e884ed

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/main/java/com/helpie/backend/controller/group/GroupController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public ResponseEntity<RecommendedResponse> getGroupsByInterest(
8282
@AuthenticationPrincipal UserVo userVo,
8383
@RequestParam(defaultValue ="0") int page
8484
){
85-
Pageable pageable= PageRequest.of(page,5,Sort.by("createdAt").descending());
85+
Pageable pageable= PageRequest.of(page,5);
8686
return ResponseEntity.ok(groupService.getGroupsByInterestV2(userVo.getId(),pageable));
8787
}
8888

src/main/java/com/helpie/backend/repository/group/GroupRepository.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,21 @@ AND g.status IN ('RECRUITING', 'RECRUITMENT_CLOSED')
4545

4646

4747

48-
@Query("""
49-
SELECT g FROM Group g
50-
WHERE g.status IN ('RECRUITING', 'RECRUITMENT_CLOSED')
51-
""")
52-
Page<Group> findByInterestFiltersV2(Pageable pageable);
48+
@Query(
49+
value = """
50+
SELECT *
51+
FROM user_groups
52+
WHERE status IN ('RECRUITING', 'RECRUITMENT_CLOSED')
53+
ORDER BY RAND(:seed)
54+
""",
55+
countQuery = """
56+
SELECT COUNT(*)
57+
FROM user_groups
58+
WHERE status IN ('RECRUITING', 'RECRUITMENT_CLOSED')
59+
""",
60+
nativeQuery = true
61+
)
62+
Page<Group> findByInterestFiltersV2(@Param("seed") long seed, Pageable pageable);
5363

5464

5565

0 commit comments

Comments
 (0)