Skip to content

Comments

[feature]모집중 검색 시 상시 모집도 검색 & 모집중,상시모집,모집마감 순으로 검색 정렬#514

Merged
lepitaaar merged 2 commits intodevelop/befrom
feature/#513-search-always-MOA-42
Jun 12, 2025
Merged

[feature]모집중 검색 시 상시 모집도 검색 & 모집중,상시모집,모집마감 순으로 검색 정렬#514
lepitaaar merged 2 commits intodevelop/befrom
feature/#513-search-always-MOA-42

Conversation

@Zepelown
Copy link
Member

@Zepelown Zepelown commented Jun 10, 2025

#️⃣연관된 이슈

#513

📝작업 내용

  • 모집 중 검색 시에 상시 모집도 추가
  • 검색 시 정렬 기준을 모집 중 > 상시 모집 > 모집 종료 로 설정

중점적으로 리뷰받고 싶은 부분(선택)

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

아직까진 다큐먼트의 필드값을 하드코딩하는 방식으로만 집계 쿼리를 날릴 수 밖에 없다고 합니다.
유감,..

Summary by CodeRabbit

  • 버그 수정
    • 동아리 모집 상태가 "OPEN"으로 검색될 때 "ALWAYS"와 "OPEN" 상태 모두가 함께 조회되도록 개선되었습니다.
  • 기타
    • 모집 상태 우선순위가 조정되어 "OPEN"이 "ALWAYS"보다 높은 우선순위를 갖도록 변경되었습니다.
  • 테스트
    • 모집 상태 기준 정렬 테스트의 예상 결과 순서가 업데이트되었습니다.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

"""

Walkthrough

ClubRecruitmentStatus 열거형에서 ALWAYS와 OPEN의 우선순위 값이 서로 바뀌었습니다. ClubSearchRepository의 getMatchedCriteria 메서드는 모집 상태가 "OPEN"일 때 "ALWAYS"와 "OPEN" 모두를 대상으로 검색하도록 수정되었습니다. 다른 로직은 변경되지 않았습니다.

Changes

파일/그룹 변경 요약
.../enums/ClubRecruitmentStatus.java ALWAYS와 OPEN의 priority 값을 서로 교체
.../repository/ClubSearchRepository.java 모집 상태가 "OPEN"일 때 "ALWAYS"와 "OPEN" 모두를 검색하도록 수정
.../service/ClubSearchServiceTest.java 모집 상태 정렬 테스트에서 예상 정렬 순서 변경

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ClubSearchRepository
    participant Database

    User->>ClubSearchRepository: 모집 상태로 "OPEN" 검색 요청
    ClubSearchRepository->>Database: clubRecruitmentStatus in ["OPEN", "ALWAYS"] 조건으로 조회
    Database-->>ClubSearchRepository: 결과 반환
    ClubSearchRepository-->>User: 검색 결과 반환
Loading

Assessment against linked issues

Objective Addressed Explanation
모집 중 검색 시에 상시 모집도 추가 (MOA-42)
검색 시 정렬 기준을 모집 중 > 상시 모집 > 모집 종료로 설정 (MOA-42)

Assessment against linked issues: Out-of-scope changes

해당 변경사항에서 요구사항과 무관한 변경은 발견되지 않았습니다.
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01aa736 and 146f6d6.

📒 Files selected for processing (1)
  • backend/src/test/java/moadong/club/service/ClubSearchServiceTest.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (1)
backend/src/test/java/moadong/club/service/ClubSearchServiceTest.java (1)

54-54: 테스트 어설션이 업데이트된 비즈니스 요구사항을 정확히 반영합니다.

변경된 정렬 순서가 PR 목표인 "모집중(OPEN), 상시모집(ALWAYS), 모집마감(CLOSED)" 우선순위와 일치합니다. club1(OPEN)이 club4(ALWAYS)보다 앞에 오도록 수정된 것이 올바릅니다.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Zepelown Zepelown changed the title feat: 모집중 검색 시 상시 모집도 검색 & 모집중,상시모집,모집마감 순으로 검색 정렬 [feature]모집중 검색 시 상시 모집도 검색 & 모집중,상시모집,모집마감 순으로 검색 정렬 Jun 10, 2025
@github-actions
Copy link

github-actions bot commented Jun 10, 2025

Test Results

76 tests   76 ✅  2s ⏱️
12 suites   0 💤
12 files     0 ❌

Results for commit 146f6d6.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 429c4c7 and 01aa736.

📒 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 java

Length 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 계층 정렬 방식을 유지할지 결정해주세요.

Comment on lines +73 to +84
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)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

검색 로직 개선이 PR 목표를 달성하지만 구현 방식을 개선할 수 있습니다.

"모집중" 검색 시 "상시모집"도 포함하는 로직이 올바르게 구현되었습니다. 하지만 다음 사항들을 고려해보세요:

  1. ClubRecruitmentStatus.OPEN.toString()의 반환값이 "OPEN"인지 확인이 필요합니다.
  2. 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.

Suggested change
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.

Copy link
Contributor

@lepitaaar lepitaaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다~

Copy link
Collaborator

@Due-IT Due-IT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 👍

Copy link
Collaborator

@PororoAndFriends PororoAndFriends left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

@lepitaaar lepitaaar merged commit c064819 into develop/be Jun 12, 2025
3 checks passed
@Zepelown Zepelown deleted the feature/#513-search-always-MOA-42 branch July 28, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants