Repository navigation
[Fix/#105, #106] 자녀 스티커 startDate null 필터링 및 성장탭 CHILD 유저 필터링 추가 - #107
Conversation
📝 WalkthroughWalkthroughThe changes fix two data filtering bugs: adding UserType.CHILD filtering to GrowthService to exclude parent users from children growth results, and adding null startDate filtering to StickerQueryService to exclude incomplete sticker board entries. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
src/main/java/com/swyp/server/domain/growth/service/GrowthService.java (1)
79-87: Consider de-duplicating child filtering logic.The same child predicate is repeated twice. Precomputing a single
List<User>of valid child users would reduce drift risk and simplify future edits.♻️ Suggested refactor
List<FamilyRelation> relations = familyRelationRepository.findAllByOwnerUserId(parentId); -List<Long> childIds = - relations.stream() - .filter( - r -> - r.getTargetUser() != null - && r.getTargetUser().getUserType() - == UserType.CHILD) - .map(r -> r.getTargetUser().getId()) - .toList(); +List<User> childUsers = + relations.stream() + .map(FamilyRelation::getTargetUser) + .filter(u -> u != null && u.getUserType() == UserType.CHILD) + .toList(); + +List<Long> childIds = childUsers.stream().map(User::getId).toList(); ... List<ChildGrowthResponse> children = - relations.stream() - .filter( - r -> - r.getTargetUser() != null - && r.getTargetUser().getUserType() - == UserType.CHILD) - .map( - relation -> { - User child = relation.getTargetUser(); + childUsers.stream() + .map( + child -> { int todoStarCount = calculateTodoStarCount( child.getId(), startDate, endDate); int habitCompletedDays = habitCompletionCountMap .getOrDefault(child.getId(), 0L) .intValue(); int habitStarCount = calculateHabitStarCount(habitCompletedDays); return new ChildGrowthResponse( child.getId(), child.getNickname(), todoStarCount, habitStarCount, weekRange); }) .toList();Also applies to: 100-127
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/swyp/server/domain/growth/service/GrowthService.java` around lines 79 - 87, Refactor the duplicated child-predicate by precomputing a single collection of valid child users from relations (e.g., build a List<User> of entries where r.getTargetUser() != null && r.getTargetUser().getUserType() == UserType.CHILD) and then derive childIds from that list; replace the repeated filters at the getTargetUser()/UserType.CHILD checks (used around variables like childIds and other logic in the 100-127 region) to consume the precomputed list so the predicate is declared once and reused.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/main/java/com/swyp/server/domain/growth/service/GrowthService.java`:
- Around line 79-87: Refactor the duplicated child-predicate by precomputing a
single collection of valid child users from relations (e.g., build a List<User>
of entries where r.getTargetUser() != null && r.getTargetUser().getUserType() ==
UserType.CHILD) and then derive childIds from that list; replace the repeated
filters at the getTargetUser()/UserType.CHILD checks (used around variables like
childIds and other logic in the 100-127 region) to consume the precomputed list
so the predicate is declared once and reused.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 13b78fd8-541d-4b71-9d01-81a8437d49ea
📒 Files selected for processing (2)
src/main/java/com/swyp/server/domain/growth/service/GrowthService.javasrc/main/java/com/swyp/server/domain/sticker/service/StickerQueryService.java
📌 관련 이슈
✨ 변경 사항
📚 리뷰어 참고 사항
✅ 체크리스트
Summary by CodeRabbit