[feature]모집중 검색 시 상시 모집도 검색 & 모집중,상시모집,모집마감 순으로 검색 정렬#514
[feature]모집중 검색 시 상시 모집도 검색 & 모집중,상시모집,모집마감 순으로 검색 정렬#514lepitaaar merged 2 commits intodevelop/befrom
Conversation
|
""" WalkthroughClubRecruitmentStatus 열거형에서 ALWAYS와 OPEN의 우선순위 값이 서로 바뀌었습니다. ClubSearchRepository의 getMatchedCriteria 메서드는 모집 상태가 "OPEN"일 때 "ALWAYS"와 "OPEN" 모두를 대상으로 검색하도록 수정되었습니다. 다른 로직은 변경되지 않았습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ClubSearchRepository
participant Database
User->>ClubSearchRepository: 모집 상태로 "OPEN" 검색 요청
ClubSearchRepository->>Database: clubRecruitmentStatus in ["OPEN", "ALWAYS"] 조건으로 조회
Database-->>ClubSearchRepository: 결과 반환
ClubSearchRepository-->>User: 검색 결과 반환
Assessment against linked issues
Assessment against linked issues: Out-of-scope changes해당 변경사항에서 요구사항과 무관한 변경은 발견되지 않았습니다. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Test Results76 tests 76 ✅ 2s ⏱️ Results for commit 146f6d6. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
backend/src/main/java/moadong/club/repository/ClubSearchRepository.java (1)
59-60: 🛠️ Refactor suggestion우선순위 기반 정렬이 누락되었습니다.
현재 정렬은 division과 category만 기준으로 하고 있습니다. PR 목표인 "모집중, 상시모집, 모집마감" 순서로 정렬하려면 recruitmentStatus의 우선순위 기반 정렬이 필요합니다.
정렬 단계에 우선순위 기반 정렬을 추가해야 합니다:
operations.add( - Aggregation.sort(Sort.by(Sort.Order.asc("division"), Sort.Order.asc("category")))); + Aggregation.sort(Sort.by( + Sort.Order.asc("recruitmentStatusPriority"), + Sort.Order.asc("division"), + Sort.Order.asc("category"))));그리고 projection 단계에서 우선순위 필드를 추가해야 합니다. 하지만 MongoDB aggregation에서 Java enum의 priority 값을 직접 사용하기 어려우므로, 문서에서 언급한 대로 하드코딩된 값을 사용하거나 별도의 매핑 로직이 필요할 수 있습니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/src/main/java/moadong/club/enums/ClubRecruitmentStatus.java(1 hunks)backend/src/main/java/moadong/club/repository/ClubSearchRepository.java(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (3)
backend/src/main/java/moadong/club/enums/ClubRecruitmentStatus.java (1)
9-10: 우선순위 조정이 PR 목표와 일치합니다.OPEN("모집중")을 우선순위 1로, ALWAYS("상시모집")를 우선순위 2로 변경하여 PR에서 명시한 정렬 순서 "모집중, 상시모집, 모집마감"을 올바르게 구현했습니다.
backend/src/main/java/moadong/club/repository/ClubSearchRepository.java (2)
6-6: 필요한 import 추가가 적절합니다.ClubRecruitmentStatus enum 사용을 위한 import가 올바르게 추가되었습니다.
51-57:Details
❓ Verification inconclusive
우선순위 기반 정렬을 위한 projection 필드 검증이 필요합니다.
현재 projection에서는 recruitmentStatus만 포함하고 있지만, PR에서 언급한 정렬 순서를 구현하려면 우선순위 값도 포함되어야 합니다.
다음 스크립트로 다른 정렬 구현이 있는지 확인하겠습니다:
🏁 Script executed:
#!/bin/bash # MongoDB aggregation에서 우선순위 기반 정렬 구현 확인 # 우선순위 관련 정렬 로직 검색 rg -A 10 -B 5 "priority|Priority" --type java # 다른 aggregation에서의 정렬 패턴 검색 rg -A 5 -B 5 "Sort.*recruitmentStatus|recruitmentStatus.*Sort" --type java # ClubRecruitmentStatus의 getPriorityFromString 사용처 검색 rg -A 5 -B 5 "getPriorityFromString" --type javaLength of output: 11782
정렬 로직 위치 및 우선순위 필드 포함 검토
현재
ClubSearchRepository의 MongoDB aggregation 단계에는$sort스테이지가 없으며, 실제 정렬은
ClubSearchService에서 Java Streams.sorted()를 사용해 수행되고 있습니다.
만약 aggregation 단계에서 우선순위 기반 정렬을 실행하려면, projection에 우선순위 값을 추가한 뒤$sort스테이지를 삽입해야 합니다.
- repository: aggregation 내
$sort미적용 확인- service:
.sorted(ClubRecruitmentStatus.getPriorityFromString(...))및
.thenComparingInt(ClubCategory.getPriorityFromString(...))로 정렬aggregation 단계로 이동할지, service 계층 정렬 방식을 유지할지 결정해주세요.
| List<String> targetStatuses = new ArrayList<>(); | ||
|
|
||
| if (recruitmentStatus.equalsIgnoreCase(ClubRecruitmentStatus.OPEN.toString())) { | ||
| targetStatuses.add(ClubRecruitmentStatus.ALWAYS.toString()); | ||
| targetStatuses.add(ClubRecruitmentStatus.OPEN.toString()); | ||
| } else { | ||
| targetStatuses.add(recruitmentStatus); | ||
| } | ||
|
|
||
| criteriaList.add( | ||
| Criteria.where("recruitmentInformation.clubRecruitmentStatus").is(recruitmentStatus)); | ||
| Criteria.where("recruitmentInformation.clubRecruitmentStatus").in(targetStatuses) | ||
| ); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
검색 로직 개선이 PR 목표를 달성하지만 구현 방식을 개선할 수 있습니다.
"모집중" 검색 시 "상시모집"도 포함하는 로직이 올바르게 구현되었습니다. 하지만 다음 사항들을 고려해보세요:
ClubRecruitmentStatus.OPEN.toString()의 반환값이 "OPEN"인지 확인이 필요합니다.- enum의 name()과 toString()이 다를 수 있으므로 명시적으로 name()을 사용하는 것이 더 안전합니다.
다음과 같이 개선할 수 있습니다:
- if (recruitmentStatus.equalsIgnoreCase(ClubRecruitmentStatus.OPEN.toString())) {
- targetStatuses.add(ClubRecruitmentStatus.ALWAYS.toString());
- targetStatuses.add(ClubRecruitmentStatus.OPEN.toString());
+ if (recruitmentStatus.equalsIgnoreCase(ClubRecruitmentStatus.OPEN.name())) {
+ targetStatuses.add(ClubRecruitmentStatus.ALWAYS.name());
+ targetStatuses.add(ClubRecruitmentStatus.OPEN.name());📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| List<String> targetStatuses = new ArrayList<>(); | |
| if (recruitmentStatus.equalsIgnoreCase(ClubRecruitmentStatus.OPEN.toString())) { | |
| targetStatuses.add(ClubRecruitmentStatus.ALWAYS.toString()); | |
| targetStatuses.add(ClubRecruitmentStatus.OPEN.toString()); | |
| } else { | |
| targetStatuses.add(recruitmentStatus); | |
| } | |
| criteriaList.add( | |
| Criteria.where("recruitmentInformation.clubRecruitmentStatus").is(recruitmentStatus)); | |
| Criteria.where("recruitmentInformation.clubRecruitmentStatus").in(targetStatuses) | |
| ); | |
| List<String> targetStatuses = new ArrayList<>(); | |
| if (recruitmentStatus.equalsIgnoreCase(ClubRecruitmentStatus.OPEN.name())) { | |
| targetStatuses.add(ClubRecruitmentStatus.ALWAYS.name()); | |
| targetStatuses.add(ClubRecruitmentStatus.OPEN.name()); | |
| } else { | |
| targetStatuses.add(recruitmentStatus); | |
| } | |
| criteriaList.add( | |
| Criteria.where("recruitmentInformation.clubRecruitmentStatus").in(targetStatuses) | |
| ); |
🤖 Prompt for AI Agents
In backend/src/main/java/moadong/club/repository/ClubSearchRepository.java
around lines 73 to 84, the code uses toString() on enum values which may not
reliably return the enum name. Replace all toString() calls on
ClubRecruitmentStatus enum with name() to explicitly get the enum constant name,
ensuring consistent and correct string comparisons and database queries.
#️⃣연관된 이슈
#513
📝작업 내용
중점적으로 리뷰받고 싶은 부분(선택)
논의하고 싶은 부분(선택)
🫡 참고사항
아직까진 다큐먼트의 필드값을 하드코딩하는 방식으로만 집계 쿼리를 날릴 수 밖에 없다고 합니다.
유감,..
Summary by CodeRabbit