-
Notifications
You must be signed in to change notification settings - Fork 3
[MERGE] dev -> main 병합 #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,21 +15,20 @@ | |||||||||||||||||||||||||||||||||||||||||||||
| import java.util.Optional; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| public interface PotRepository extends JpaRepository<Pot, Long> { | ||||||||||||||||||||||||||||||||||||||||||||||
| Page<Pot> findByRecruitmentDetails_RecruitmentRole(Role recruitmentRole, Pageable pageable); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Optional<Pot> findPotWithRecruitmentDetailsByPotId(Long potId); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| List<Pot> findByPotApplication_User_Id(Long userId); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| List<Pot> findByUserId(Long userId); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Page<Pot> findAll(Pageable pageable); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| List<Pot> findByPotMembers_UserIdAndPotStatusOrderByCreatedAtDesc(Long userId, String status); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| List<Pot> findByUserIdAndPotStatus(Long userId, String status); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Page<Pot> findByUserIdAndPotStatus(Long userId, String potStatus, Pageable pageable); | ||||||||||||||||||||||||||||||||||||||||||||||
| @Query("SELECT p FROM Pot p WHERE p.user.id = :userId AND p.potStatus = :potStatus ORDER BY p.createdAt DESC") | ||||||||||||||||||||||||||||||||||||||||||||||
| Page<Pot> findByUserIdAndPotStatusOrderByCreatedAtDesc(@Param("userId") Long userId, | ||||||||||||||||||||||||||||||||||||||||||||||
| @Param("potStatus") String potStatus, | ||||||||||||||||||||||||||||||||||||||||||||||
| Pageable pageable); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Query("SELECT p FROM Pot p " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "WHERE LOWER(p.potName) LIKE LOWER(CONCAT('%', :keyword, '%')) " + | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -49,33 +48,26 @@ public interface PotRepository extends JpaRepository<Pot, Long> { | |||||||||||||||||||||||||||||||||||||||||||||
| "SELECT pm FROM PotMember pm WHERE pm.pot = p AND pm.user.id = :userId)") | ||||||||||||||||||||||||||||||||||||||||||||||
| List<Pot> findCompletedPotsByUserId(@Param("userId") Long userId); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| List<Pot> findByPotMembers_User_Id(Long potMembersUserId); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @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") | ||||||||||||||||||||||||||||||||||||||||||||||
| List<Pot> findCompletedPotsCreatedByUser(@Param("userId") Long userId, @Param("cursor") Long cursor); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @Modifying | ||||||||||||||||||||||||||||||||||||||||||||||
| @Query("DELETE FROM Pot f WHERE f.user.id = :userId") | ||||||||||||||||||||||||||||||||||||||||||||||
| void deleteByUserId(@Param("userId") Long userId); | ||||||||||||||||||||||||||||||||||||||||||||||
| // @Modifying | ||||||||||||||||||||||||||||||||||||||||||||||
| // @Query("DELETE FROM Pot p WHERE p.user.id = :userId AND p.potId IN :potIds AND p.potStatus = 'RECRUITING'") | ||||||||||||||||||||||||||||||||||||||||||||||
| // void deleteByUserIdAndPotIds(@Param("userId") Long userId, @Param("potIds") List<Long> potIds); | ||||||||||||||||||||||||||||||||||||||||||||||
| boolean existsByUserId(Long userId); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // 지원자 수 기준으로 모든 Pot 정렬 | ||||||||||||||||||||||||||||||||||||||||||||||
| @Query("SELECT p FROM Pot p LEFT JOIN PotApplication pa ON p = pa.pot " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "WHERE p.potStatus = :potStatus " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "GROUP BY p " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "ORDER BY COUNT(pa.applicationId) DESC, p.createdAt DESC") | ||||||||||||||||||||||||||||||||||||||||||||||
| Page<Pot> findAllOrderByApplicantsCountDesc(Pageable pageable); | ||||||||||||||||||||||||||||||||||||||||||||||
| "ORDER BY p.createdAt DESC, COUNT(pa.applicationId) DESC ") | ||||||||||||||||||||||||||||||||||||||||||||||
| Page<Pot> findAllOrderByApplicantsCountDesc(@Param("potStatus") String potStatus, Pageable pageable); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// 여러 Role을 기준으로 지원자 수 많은 순 정렬 | ||||||||||||||||||||||||||||||||||||||||||||||
| @Query("SELECT p FROM Pot p " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "LEFT JOIN PotRecruitmentDetails prd ON p = prd.pot " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "LEFT JOIN PotApplication pa ON p = pa.pot " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "WHERE prd.recruitmentRole IN :roles " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "WHERE prd.recruitmentRole IN :roles AND p.potStatus = :potStatus " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "GROUP BY p " + | ||||||||||||||||||||||||||||||||||||||||||||||
| "ORDER BY COUNT(pa.applicationId) DESC, p.createdAt DESC") | ||||||||||||||||||||||||||||||||||||||||||||||
| Page<Pot> findByRecruitmentRolesInOrderByApplicantsCountDesc(@Param("roles") List<Role> roles, Pageable pageable); | ||||||||||||||||||||||||||||||||||||||||||||||
| "ORDER BY p.createdAt DESC, COUNT(pa.applicationId) DESC ") | ||||||||||||||||||||||||||||||||||||||||||||||
| Page<Pot> findByRecruitmentRolesInOrderByApplicantsCountDesc(@Param("roles") List<Role> roles, @Param("potStatus") String potStatus, Pageable pageable); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+67
to
71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 집계 값 왜곡 가능성(CROSS JOIN 중복) 및 정렬 순서 수정 필요 prd/pa 이중 조인으로 pa 행이 곱연산되어 COUNT가 과대집계될 수 있습니다. DISTINCT로 방지하고, 정렬도 지원자 수 우선으로 수정, countQuery를 명시하세요. - @Query("SELECT p FROM Pot p " +
- "LEFT JOIN PotRecruitmentDetails prd ON p = prd.pot " +
- "LEFT JOIN PotApplication pa ON p = pa.pot " +
- "WHERE prd.recruitmentRole IN :roles AND p.potStatus = :potStatus " +
- "GROUP BY p " +
- "ORDER BY p.createdAt DESC, COUNT(pa.applicationId) DESC ")
+ @Query(value = "SELECT p FROM Pot p " +
+ "LEFT JOIN p.recruitmentDetails prd " +
+ "LEFT JOIN p.potApplication pa " +
+ "WHERE prd.recruitmentRole IN :roles AND p.potStatus = :potStatus " +
+ "GROUP BY p " +
+ "ORDER BY COUNT(DISTINCT pa.applicationId) DESC, p.createdAt DESC",
+ countQuery = "SELECT COUNT(DISTINCT p.potId) FROM Pot p " +
+ "LEFT JOIN p.recruitmentDetails prd " +
+ "WHERE prd.recruitmentRole IN :roles AND p.potStatus = :potStatus")
Page<Pot> findByRecruitmentRolesInOrderByApplicantsCountDesc(@Param("roles") List<Role> roles, @Param("potStatus") String potStatus, Pageable pageable);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| List<Pot> findByPotMembers_UserIdOrderByCreatedAtDesc(Long userId); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
메서드명-정렬 불일치 및 카운트 쿼리 부재
메서드명은 ApplicantsCountDesc지만 JPQL은 createdAt 우선입니다. 또한 GROUP BY가 있어 자동 count 쿼리 효율 저하 가능. 아래처럼 정렬 순서와 countQuery를 명시해주세요.
📝 Committable suggestion
🤖 Prompt for AI Agents