Conversation
|
Caution Review failedThe pull request is closed. 🔍 변경 사항 분석📋 개요그룹 생성 및 참여 시 사용자의 참여/생성 횟수를 추적하기 위해 📊 변경 사항 목록
⏱️ 코드 리뷰 예상 시간🎯 3 (중간) | ⏱️ ~20분 추가 검토 권장 사항:
🔗 관련 가능성 있는 PR
🐰 변경을 축하하는 토끼의 시
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request introduces denormalization of group participation and creation counts in the User entity. The changes aim to maintain counters for how many groups a user has joined (groupJoinedCount) and created (groupCreatedCount), eliminating the need for aggregation queries to retrieve these statistics.
Key Changes:
- Added increment logic for
groupJoinedCountandgroupCreatedCountwhen users create or join groups for the first time - Introduced a new repository query method
findAllByGroupAndStatusFetchUserto efficiently fetch group users with user data - Updated HTTP test data to use future dates (2026 instead of 2025)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/test/http/group/group-cancel.http | Updated test data dates from 2025 to 2026 to use future dates |
| src/main/java/team/wego/wegobackend/group/domain/repository/GroupUserRepository.java | Added fetch join query method to retrieve group users with their user entities |
| src/main/java/team/wego/wegobackend/group/application/service/GroupService.java | Implemented counter increments for group creation and first-time joins; added helper method for batch counter decrements (currently unused) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "startTime": "2026-12-11T19:00:00", | ||
| "endTime": "2026-12-11T21:00:00", |
There was a problem hiding this comment.
While updating the hardcoded dates from 2025 to 2026 fixes the immediate issue of past dates, consider using relative dates in test data to prevent this maintenance burden in the future. For example, you could use a date calculation like "now + 30 days" to ensure test data always uses future dates without manual updates.
| private void decreaseJoinedCountForAttenders(Group group) { | ||
| List<GroupUser> attenders = groupUserRepository.findAllByGroupAndStatusFetchUser(group, | ||
| ATTEND); | ||
|
|
||
| attenders.forEach(gu -> gu.getUser().decreaseGroupJoinedCount()); | ||
| } |
There was a problem hiding this comment.
The method decreaseJoinedCountForAttenders is defined but never called in the deleteGroup method above (lines 556-581). When a group is deleted, all attending users should have their groupJoinedCount decremented, and the host should have their groupCreatedCount decremented. Currently, these counters will become inaccurate when groups are deleted. Call this method before deleting the group, and also add logic to decrease the host's groupCreatedCount.
| """) | ||
| List<GroupUser> findAllByGroupAndStatusFetchUser( | ||
| @Param("group") Group group, | ||
| @Param("status") GroupUserStatus status); |
There was a problem hiding this comment.
The new query method findAllByGroupAndStatusFetchUser is added but appears to only be used in the decreaseJoinedCountForAttenders method, which itself is not being called anywhere in the codebase. This suggests that the implementation for decreasing counters when groups are deleted is incomplete. Ensure this method is properly utilized in the delete group workflow.
| @Param("status") GroupUserStatus status); | |
| @Param("status") GroupUserStatus status); | |
| /** | |
| * Returns the list of users who are attending the given group. | |
| * Intended for use in the group deletion workflow to update user joined counts. | |
| * The caller should decrement the joined count for each user and persist the changes. | |
| */ | |
| default List<User> findAttendingUsersForGroup(Group group) { | |
| return findAllByGroupAndStatusFetchUser(group, GroupUserStatus.ATTENDING) | |
| .stream() | |
| .map(GroupUser::getUser) | |
| .toList(); | |
| } |
| private void registerHost(Group group, User host) { | ||
| GroupUser groupUser = GroupUser.create(group, host, GroupRole.HOST); | ||
| groupUserRepository.save(groupUser); | ||
|
|
||
| host.increaseGroupJoinedCount(); | ||
| host.increaseGroupCreatedCount(); | ||
| } |
There was a problem hiding this comment.
The method name registerHost could be more descriptive. Consider renaming it to something like saveHostAndIncrementCounters or registerHostWithCounters to make it clear that this method not only saves the host as a GroupUser but also increments denormalized counters. This would make the side effects more obvious to future maintainers.
| // 유니크 참여 카운트는 "처음 참여"일 때만 올리기 | ||
| if (groupUser == null) { | ||
| // 처음 참여 | ||
| GroupUser newGroupUser = GroupUser.create(group, member, GroupRole.MEMBER); | ||
| groupUserRepository.save(newGroupUser); | ||
|
|
||
| member.increaseGroupJoinedCount(); |
There was a problem hiding this comment.
The comment mentions incrementing a "유니크 참여 카운트" (unique participation count) but the counter being incremented is simply called groupJoinedCount. Consider adding more comprehensive documentation about the denormalization strategy, such as explaining that the counter tracks the number of unique groups a user has ever joined (not re-joins), and why this distinction matters for the business logic.
📝 Pull Request
📌 PR 종류
해당하는 항목에 체크해주세요.
✨ 변경 내용
모임 엔티티에 추가된 모임 생성과 참여를 기록하도록 회원 모임 참여와 생성 반정규화 합니다.
모임 참여 횟수와 모임 생성 횟수
🔍 관련 이슈
🧪 테스트
변경된 기능에 대한 테스트 범위 또는 테스트 결과를 작성해주세요.
🚨 확인해야 할 사항 (Checklist)
PR을 제출하기 전에 아래 항목들을 확인해주세요.
🙋 기타 참고 사항
리뷰어가 참고하면 좋을 만한 추가 설명이 있다면 적어주세요.
Summary by CodeRabbit
릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings.