Skip to content

Conversation

@seongjunnoh
Copy link
Collaborator

@seongjunnoh seongjunnoh commented Aug 21, 2025

#️⃣ 연관된 이슈

📝 작업 내용

  • main 브랜치에 바로 hotfix 한

    • '내 모임방 목록 조회 api'
    • '모임홈, 내가 참여한 진행중인 모임방 조회 api'

    수정 코드를 develop 브랜치에도 적용

📸 스크린샷

💬 리뷰 요구사항

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

📌 PR 진행 시 이러한 점들을 참고해 주세요

* P1 : 꼭 반영해 주세요 (Request Changes) - 이슈가 발생하거나 취약점이 발견되는 케이스 등
* P2 : 반영을 적극적으로 고려해 주시면 좋을 것 같아요 (Comment)
* P3 : 이런 방법도 있을 것 같아요~ 등의 사소한 의견입니다 (Chore)

Summary by CodeRabbit

  • 신규 기능
    • 없음
  • 버그 수정
    • 내 방 목록 및 참여 관련 조회에서 참여자 상태 필터를 강화해, 탈퇴(비활성)한 참여자를 제외하도록 개선했습니다. 이로써 내 방 목록과 방의 현재 인원수가 정확히 반영됩니다.
  • 테스트
    • 사용자가 탈퇴한 방이 내 방 목록에서 제외되는지와 방 이름 및 인원수 표시가 정확한지 검증하는 시나리오 테스트를 추가/수정했습니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 21, 2025

Walkthrough

사용자 참가 상태 필터(participant.status = ACTIVE)를 추가하여 참가자 기반 룸 조회 쿼리들이 활성 참여자만 반환하도록 변경했고, 관련 테스트를 추가·수정하여 탈퇴(INACTIVE)한 참여자가 /rooms/my 응답에서 제외되는지 검증합니다.

Changes

Cohort / File(s) Summary
참가자 상태 필터 추가
src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java
사용자-참여 기반 룸 조회 쿼리들에 participant.status.eq(StatusType.ACTIVE) 조건을 추가(검색 대상: searchHomeJoinedRooms, findRecruitingRoomsUserParticipated, findPlayingRoomsUserParticipated, findPlayingAndRecruitingRoomsUserParticipated, findExpiredRoomsUserParticipated). 정렬/페이징/기간 조건은 변경 없음.
나의 방 API 테스트 보강
src/test/java/konkuk/thip/room/adapter/in/web/RoomShowMineApiTest.java
JdbcTemplate 주입 추가, saveSingleUserToRoomRoomParticipantJpaEntity 반환으로 변경. 테스트에서 일부 참여자의 상태를 INACTIVE로 업데이트(탈퇴 시뮬레이션)하고 /rooms/my가 탈퇴한 방을 제외하는지 검증하는 신규 테스트 추가/수정.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as 사용자
  participant API as RoomController (/rooms/my)
  participant SVC as RoomService
  participant REPO as RoomQueryRepositoryImpl
  participant DB as Database

  U->>API: GET /rooms/my
  API->>SVC: findMyRooms(userId)
  SVC->>REPO: findPlayingAndRecruitingRoomsUserParticipated(userId)
  REPO->>DB: SELECT ... WHERE participant.userId=? AND participant.status=ACTIVE
  DB-->>REPO: rows (활성 참여자만)
  REPO-->>SVC: 룸 목록
  SVC-->>API: DTO 반환
  API-->>U: 200 OK (탈퇴 방 제외)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

⚡️ fix

Suggested reviewers

  • hd0rable
  • buzz0331

Poem

풀밭에 깡총 깡총 쿵쿵,
탈퇴한 발자국은 살짝 둥!
ACTIVE만 쏙쏙 골라 담아,
내 방 목록 뽀송히 정리했네. 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b9b195a and 01976d9.

📒 Files selected for processing (1)
  • src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch main

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@seongjunnoh seongjunnoh changed the title main 브랜치에 바로 적용한 hotfix 변경사항 develop 브랜치 에도 적용 [chore] main 브랜치에 바로 적용한 hotfix 변경사항 develop 브랜치 에도 적용 Aug 21, 2025
@github-actions
Copy link

github-actions bot commented Aug 21, 2025

Test Results

412 tests  +1   412 ✅ +1   31s ⏱️ ±0s
124 suites ±0     0 💤 ±0 
124 files   ±0     0 ❌ ±0 

Results for commit 01976d9. ± Comparison against base commit 8004dff.

♻️ This comment has been updated with latest results.

Copy link

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java (1)

201-213: Home용 참여 방 조회(searchHomeJoinedRooms)도 ACTIVE 참여자만 조회하도록 정렬

동일한 도메인 규칙이라면 Home 섹션의 참여 방 목록도 INACTIVE 참여자를 제외해야 합니다. 현재 where 절에 참여자 상태 조건이 없습니다. 다음과 같이 보강하는 것을 권장합니다.

 BooleanBuilder where = new BooleanBuilder();
 where.and(participant.userJpaEntity.userId.eq(userId));
+where.and(participant.status.eq(StatusType.ACTIVE));
 where.and(room.startDate.loe(date));
 where.and(room.endDate.goe(date));
🧹 Nitpick comments (7)
src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java (4)

431-438: 서브쿼리 userJoinedRoom에 ACTIVE 조건 누락 — 재참여/추천 노출에 영향 가능

현재는 유저가 과거에 참여했다가 탈퇴(INACTIVE)한 방도 “참여한 방”으로 간주되어 추천/미참여 필터에 걸릴 수 있습니다. 의도적으로 “한 번이라도 참여했으면 제외”라면 OK이지만, 보통은 ACTIVE 참여만 인정하는 것이 자연스럽습니다. 확인 부탁드립니다. ACTIVE만 인정한다면 아래처럼 수정 제안드립니다.

 private BooleanExpression userJoinedRoom(Long userId) {
     return JPAExpressions
             .selectOne()
             .from(participant)
-            .where(participant.userJpaEntity.userId.eq(userId)
-                    .and(participant.roomJpaEntity.roomId.eq(room.roomId)))
+            .where(participant.userJpaEntity.userId.eq(userId)
+                    .and(participant.roomJpaEntity.roomId.eq(room.roomId))
+                    .and(participant.status.eq(StatusType.ACTIVE)))
             .exists();
 }

173-187: 추천(‘다른 모집중인 방’)에도 방 상태 ACTIVE 필터 일관 적용 제안

다른 쿼리들처럼 room.status.eq(StatusType.ACTIVE) 조건을 넣어 비활성화된 방이 추천에 노출되지 않도록 일관성 유지가 필요해 보입니다.

 .where(
     room.category.eq(category)
             .and(room.startDate.after(LocalDate.now()))
             .and(room.roomId.ne(roomId))
             .and(room.isPublic.isTrue())
+            .and(room.status.eq(StatusType.ACTIVE))
 )

264-351: 중복 조건 캡슐화: ACTIVE 참여자 조건 헬퍼로 중복 제거

네 곳에서 동일한 participant.status.eq(StatusType.ACTIVE)를 반복합니다. 헬퍼로 추출 시 가독성과 변경 용이성이 좋아집니다.

-BooleanExpression base = participant.userJpaEntity.userId.eq(userId)
-        .and(participant.status.eq(StatusType.ACTIVE))
+BooleanExpression base = participant.userJpaEntity.userId.eq(userId)
+        .and(activeParticipant())
         .and(room.startDate.after(today))
         .and(room.status.eq(StatusType.ACTIVE));
-BooleanExpression base = participant.userJpaEntity.userId.eq(userId)
-        .and(participant.status.eq(StatusType.ACTIVE))
+BooleanExpression base = participant.userJpaEntity.userId.eq(userId)
+        .and(activeParticipant())
         .and(room.startDate.loe(today))
         .and(room.endDate.goe(today))
         .and(room.status.eq(StatusType.ACTIVE));
-BooleanExpression base = participant.userJpaEntity.userId.eq(userId)
-        .and(participant.status.eq(StatusType.ACTIVE))
+BooleanExpression base = participant.userJpaEntity.userId.eq(userId)
+        .and(activeParticipant())
         .and(playing.or(recruiting))
         .and(room.status.eq(StatusType.ACTIVE));
-BooleanExpression base = participant.userJpaEntity.userId.eq(userId)
-        .and(participant.status.eq(StatusType.ACTIVE))
+BooleanExpression base = participant.userJpaEntity.userId.eq(userId)
+        .and(activeParticipant())
         .and(room.endDate.before(today))
         .and(room.status.eq(StatusType.ACTIVE));

헬퍼 추가(파일 내 임의 위치, 예: 필드들 아래):

private BooleanExpression activeParticipant() {
    return participant.status.eq(StatusType.ACTIVE);
}

271-271: 쿼리 성능 가드: 인덱스 점검(특히 userId+status 결합 인덱스)

FROM participant … WHERE participant.user_id = ? AND participant.status = 'ACTIVE' 형태가 핵심 선택 조건입니다. 다음 인덱스가 없다면 스캔 비용이 커질 수 있습니다.

  • room_participants(user_id, status) — /rooms/my
  • room_participants(room_id, status) — 방 단위 집계/검증 시
  • 필요 시 JPA 엔티티에 @Index(name = "...", columnList = "user_id,status") 추가 검토
    인덱스 유무와 선택도는 실행계획으로 한 번 확인 부탁드립니다.
src/test/java/konkuk/thip/room/adapter/in/web/RoomShowMineApiTest.java (3)

476-482: 직접 SQL 업데이트는 헬퍼로 감싸 중복·스키마 결합 최소화

테스트 내에서 동일 SQL이 반복됩니다. 헬퍼 메서드로 캡슐화하면 중복 제거와 스키마 변경 시 영향 최소화에 도움이 됩니다.

-        jdbcTemplate.update(
-                "UPDATE room_participants SET status = ? WHERE room_participant_id = ?",
-                StatusType.INACTIVE.name(), exit1.getRoomParticipantId());
-        jdbcTemplate.update(
-                "UPDATE room_participants SET status = ? WHERE room_participant_id = ?",
-                StatusType.INACTIVE.name(), exit2.getRoomParticipantId());
+        deactivateParticipant(exit1.getRoomParticipantId());
+        deactivateParticipant(exit2.getRoomParticipantId());

테스트 클래스에 보조 메서드 추가:

private void deactivateParticipant(Long roomParticipantId) {
    jdbcTemplate.update(
        "UPDATE room_participants SET status = ? WHERE room_participant_id = ?",
        StatusType.INACTIVE.name(), roomParticipantId
    );
}

91-103: 참여자 생성은 TestEntityFactory 활용 고려(초깃값 일관성 확보)

직접 빌더로 생성하면 기본값(예: currentPage, userPercentage 등) 일관성이 깨질 수 있습니다. 팩토리 메서드 사용을 권장합니다.

-    private RoomParticipantJpaEntity saveSingleUserToRoom(RoomJpaEntity roomJpaEntity, UserJpaEntity userJpaEntity) {
-        RoomParticipantJpaEntity roomParticipantJpaEntity = RoomParticipantJpaEntity.builder()
-                .userJpaEntity(userJpaEntity)
-                .roomJpaEntity(roomJpaEntity)
-                .roomParticipantRole(RoomParticipantRole.MEMBER)
-                .build();
-        RoomParticipantJpaEntity saved = roomParticipantJpaRepository.save(roomParticipantJpaEntity);
+    private RoomParticipantJpaEntity saveSingleUserToRoom(RoomJpaEntity roomJpaEntity, UserJpaEntity userJpaEntity) {
+        RoomParticipantJpaEntity roomParticipant = TestEntityFactory
+                .createRoomParticipant(roomJpaEntity, userJpaEntity, RoomParticipantRole.MEMBER, 0.0);
+        RoomParticipantJpaEntity saved = roomParticipantJpaRepository.save(roomParticipant);
         roomJpaEntity.updateMemberCount(roomJpaEntity.getMemberCount() + 1);
         roomJpaRepository.save(roomJpaEntity);
         return saved;
     }

450-494: 탈퇴 시 memberCount 반영 여부 별도 케이스로 검증 제안

본 테스트는 목록 제외만 확인합니다. 도메인 상 “방 나가기”가 memberCount 감소를 동반해야 한다면, 그 동작을 검증하는 별도 통합 테스트를 추가해 주세요(서비스·이벤트 핸들러 경로 포함). 현재는 raw SQL로 status만 바꾸므로 카운트 정합성은 커버되지 않습니다.

원하시면 케이스 초안을 드리겠습니다(나가기 API 호출 → count 감소 및 목록 제외 동시 검증).

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8004dff and b9b195a.

📒 Files selected for processing (2)
  • src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java (4 hunks)
  • src/test/java/konkuk/thip/room/adapter/in/web/RoomShowMineApiTest.java (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#113
File: src/main/java/konkuk/thip/recentSearch/adapter/out/persistence/RecentSearchCommandPersistenceAdapter.java:38-44
Timestamp: 2025-07-30T14:05:04.945Z
Learning: seongjunnoh는 코드 최적화 제안에 대해 구체적인 기술적 근거와 효율성 차이를 이해하고 싶어하며, 성능 개선 방식에 대한 상세한 설명을 선호한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#93
File: src/main/java/konkuk/thip/room/adapter/out/persistence/RoomQueryPersistenceAdapter.java:49-114
Timestamp: 2025-07-28T16:44:31.224Z
Learning: seongjunnoh는 코드 중복 문제에 대한 리팩토링 제안을 적극적으로 수용하고 함수형 인터페이스를 활용한 해결책을 선호한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#195
File: src/main/java/konkuk/thip/feed/application/mapper/FeedQueryMapper.java:0-0
Timestamp: 2025-08-13T05:22:32.287Z
Learning: seongjunnoh는 데이터 무결성과 중복 방지에 대한 고민이 깊으며, LinkedHashSet을 활용한 중복 제거와 순서 보장을 동시에 달성하는 솔루션을 선호한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#180
File: src/main/java/konkuk/thip/room/application/service/AttendanceCheckCreateService.java:22-40
Timestamp: 2025-08-14T09:15:31.371Z
Learning: seongjunnoh는 기술적 완벽성보다 실제 비즈니스 시나리오와 사용자 행동 패턴을 우선 고려하며, 발생 가능성이 낮은 엣지 케이스보다는 실용적인 구현을 선호한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#112
File: src/main/java/konkuk/thip/feed/adapter/out/persistence/repository/FeedQueryRepositoryImpl.java:272-272
Timestamp: 2025-07-30T10:44:34.115Z
Learning: seongjunnoh는 피드 커서 페이지네이션에서 LocalDateTime 단일 커서 방식을 선호하며, 복합 키 기반 커서보다 구현 단순성과 성능을 우선시한다.
🧬 Code graph analysis (1)
src/test/java/konkuk/thip/room/adapter/in/web/RoomShowMineApiTest.java (1)
src/test/java/konkuk/thip/common/util/TestEntityFactory.java (1)
  • TestEntityFactory (30-394)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/main/java/konkuk/thip/room/adapter/out/persistence/repository/RoomQueryRepositoryImpl.java (1)

271-274: ACTIVE 참여자 필터 추가로 ‘나간 방’ 배제 — 의도 충족합니다

각 쿼리의 기본 조건에 participant.status.eq(StatusType.ACTIVE)를 추가하여, 참여 이력이 INACTIVE인 방이 /rooms/my 결과에서 제외됩니다. 비즈니스 요구와 정합합니다.

Also applies to: 289-293, 310-313, 340-343

src/test/java/konkuk/thip/room/adapter/in/web/RoomShowMineApiTest.java (1)

450-494: ‘나간 방 제외’ 시나리오 커버 좋습니다

INACTIVE로 마킹한 참여 이력이 목록에서 제외되는 것을 end-to-end로 검증하고 있어 회귀 방지에 유효합니다. 정렬과 카운트 기대치도 명확합니다.

- 유저가 방에서 나가지 않고, 현재 활동중인 모임방만 조회되도록 where 절 추가
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants