Skip to content

Commit 92ff2cb

Browse files
committed
Merge branch 'main' of https://github.com/STACKPOT/STACKPOT-BE into fix/#450-qa-feedback
2 parents af1d154 + 01967ac commit 92ff2cb

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

src/main/java/stackpot/stackpot/pot/repository/PotRepository.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515
import java.util.Optional;
1616

1717
public interface PotRepository extends JpaRepository<Pot, Long> {
18-
Page<Pot> findByRecruitmentDetails_RecruitmentRole(Role recruitmentRole, Pageable pageable);
19-
2018
Optional<Pot> findPotWithRecruitmentDetailsByPotId(Long potId);
2119

2220
List<Pot> findByPotApplication_User_Id(Long userId);
2321

24-
List<Pot> findByUserId(Long userId);
25-
2622
Page<Pot> findAll(Pageable pageable);
2723

2824
List<Pot> findByPotMembers_UserIdAndPotStatusOrderByCreatedAtDesc(Long userId, String status);
2925

3026
List<Pot> findByUserIdAndPotStatus(Long userId, String status);
3127

32-
Page<Pot> findByUserIdAndPotStatus(Long userId, String potStatus, Pageable pageable);
28+
@Query("SELECT p FROM Pot p WHERE p.user.id = :userId AND p.potStatus = :potStatus ORDER BY p.createdAt DESC")
29+
Page<Pot> findByUserIdAndPotStatusOrderByCreatedAtDesc(@Param("userId") Long userId,
30+
@Param("potStatus") String potStatus,
31+
Pageable pageable);
3332

3433
@Query("SELECT p FROM Pot p " +
3534
"WHERE LOWER(p.potName) LIKE LOWER(CONCAT('%', :keyword, '%')) " +
@@ -49,33 +48,26 @@ public interface PotRepository extends JpaRepository<Pot, Long> {
4948
"SELECT pm FROM PotMember pm WHERE pm.pot = p AND pm.user.id = :userId)")
5049
List<Pot> findCompletedPotsByUserId(@Param("userId") Long userId);
5150

52-
List<Pot> findByPotMembers_User_Id(Long potMembersUserId);
53-
5451
@Query("SELECT p FROM Pot p WHERE p.user.id = :userId AND p.potStatus = 'COMPLETED' AND (:cursor IS NULL OR p.potId < :cursor) ORDER BY p.potId DESC")
5552
List<Pot> findCompletedPotsCreatedByUser(@Param("userId") Long userId, @Param("cursor") Long cursor);
5653

57-
@Modifying
58-
@Query("DELETE FROM Pot f WHERE f.user.id = :userId")
59-
void deleteByUserId(@Param("userId") Long userId);
60-
// @Modifying
61-
// @Query("DELETE FROM Pot p WHERE p.user.id = :userId AND p.potId IN :potIds AND p.potStatus = 'RECRUITING'")
62-
// void deleteByUserIdAndPotIds(@Param("userId") Long userId, @Param("potIds") List<Long> potIds);
6354
boolean existsByUserId(Long userId);
6455

6556
// 지원자 수 기준으로 모든 Pot 정렬
6657
@Query("SELECT p FROM Pot p LEFT JOIN PotApplication pa ON p = pa.pot " +
58+
"WHERE p.potStatus = :potStatus " +
6759
"GROUP BY p " +
68-
"ORDER BY COUNT(pa.applicationId) DESC, p.createdAt DESC")
69-
Page<Pot> findAllOrderByApplicantsCountDesc(Pageable pageable);
60+
"ORDER BY p.createdAt DESC, COUNT(pa.applicationId) DESC ")
61+
Page<Pot> findAllOrderByApplicantsCountDesc(@Param("potStatus") String potStatus, Pageable pageable);
7062

7163
/// 여러 Role을 기준으로 지원자 수 많은 순 정렬
7264
@Query("SELECT p FROM Pot p " +
7365
"LEFT JOIN PotRecruitmentDetails prd ON p = prd.pot " +
7466
"LEFT JOIN PotApplication pa ON p = pa.pot " +
75-
"WHERE prd.recruitmentRole IN :roles " +
67+
"WHERE prd.recruitmentRole IN :roles AND p.potStatus = :potStatus " +
7668
"GROUP BY p " +
77-
"ORDER BY COUNT(pa.applicationId) DESC, p.createdAt DESC")
78-
Page<Pot> findByRecruitmentRolesInOrderByApplicantsCountDesc(@Param("roles") List<Role> roles, Pageable pageable);
69+
"ORDER BY p.createdAt DESC, COUNT(pa.applicationId) DESC ")
70+
Page<Pot> findByRecruitmentRolesInOrderByApplicantsCountDesc(@Param("roles") List<Role> roles, @Param("potStatus") String potStatus, Pageable pageable);
7971

8072
List<Pot> findByPotMembers_UserIdOrderByCreatedAtDesc(Long userId);
8173

src/main/java/stackpot/stackpot/pot/service/pot/PotQueryServiceImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public Map<String, Object> getMyRecruitingPotsWithPaging(Integer page, Integer s
131131
User user = authService.getCurrentUser();
132132

133133
Pageable pageable = PageRequest.of(page - 1, size);
134-
Page<Pot> potPage = potRepository.findByUserIdAndPotStatus(user.getId(), "RECRUITING", pageable);
134+
Page<Pot> potPage = potRepository.findByUserIdAndPotStatusOrderByCreatedAtDesc(user.getId(), "RECRUITING", pageable);
135135

136136
List<Pot> pots = potPage.getContent();
137137

@@ -264,12 +264,12 @@ public Map<String, Object> getAllPotsWithPaging(List<Role> roles, int page, int
264264
Page<Pot> potPage;
265265

266266
if (onlyMine != null && onlyMine && user != null) {
267-
potPage = potRepository.findByUserIdAndPotStatus(user.getId(), "RECRUITING", pageable);
267+
potPage = potRepository.findByUserIdAndPotStatusOrderByCreatedAtDesc(user.getId(), "RECRUITING", pageable);
268268
} else {
269269
if (roles == null || roles.isEmpty()) {
270-
potPage = potRepository.findAllOrderByApplicantsCountDesc(pageable);
270+
potPage = potRepository.findAllOrderByApplicantsCountDesc("RECRUITING", pageable);
271271
} else {
272-
potPage = potRepository.findByRecruitmentRolesInOrderByApplicantsCountDesc(roles, pageable);
272+
potPage = potRepository.findByRecruitmentRolesInOrderByApplicantsCountDesc(roles, "RECRUITING", pageable);
273273
}
274274
}
275275

0 commit comments

Comments
 (0)