[REFACTOR] 사용자 및 주간 통계 집계 책임 분리 - #256
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough통계 집계 책임을 세 개의 서비스로 분리했다. 사용자 누적 통계와 주간 연습·스킬 통계를 각각 집계한다. Changes통계 집계 책임 분리
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to 통계 집계 책임이 사용자 누적 및 주간 통계 서비스로 분리되었으며, 이벤트별 집계 순서와 기존 집계 동작이 유지됩니다. 현재 확인된 병합 차단 위험은 없습니다. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation [
✨ Finishing Touches 💡 1📝 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 |
| LocalDate weekStart = Instant.now(clock).atZone(KOREA_ZONE_ID).toLocalDate().with(DayOfWeek.MONDAY); | ||
| LocalDate weekEnd = weekStart.plusDays(6); | ||
| LocalDate lastWeekStart = weekStart.minusWeeks(1); | ||
|
|
There was a problem hiding this comment.
p3: aggregate에서 User 조회해서 upsert/create 함수에 전달하는 방법으로 수정하는 거 어떨까요ㅎㅎ
성능은 크게 차이 없을 것 같은데, 반복 호출이 되는 것 같아서 제안해 봅니다~!
eg. User user = getUser(userId); // aggregate에서 한 번만 조회
There was a problem hiding this comment.
좋은 의견 감사합니다!
현재 User 조회는 주간 스킬 통계를 신규 생성하는 경우에만 수행되고, 기존 통계 갱신이나 집계할 점수가 없는 경우에는 수행되지 않습니다. aggregate 시작 시 User를 미리 조회하면 불필요한 조회가 추가되고, 집계 대상 점수가 없는 경우에도 USER_NOT_FOUND가 발생하는 등 기존 동작이 달라질 수 있어 이번 책임 분리 범위에서는 기존 흐름을 유지하려고 합니다.
동일 트랜잭션 내 반복 findById는 JPA 1차 캐시의 도움도 받을 수 있으므로, 실제 조회 성능 개선은 별도 PERF 이슈에서 쿼리를 측정한 뒤 함께 검토하겠습니다!
on1yoneprivate
left a comment
There was a problem hiding this comment.
굿굿!! 코멘트 단 거 참고해 주면 될 것 같습니당
📍 개요
⛓️💥 관련 이슈
🛠️ 작업 내용
UserStatisticsAggregationService로 분리WeeklyPracticeStatisticsAggregationService로 분리WeeklySkillStatisticsAggregationService로 분리StatisticsAggregationService가 이벤트별 집계 순서만 제어하도록 변경REQUIRES_NEW트랜잭션 경계와 Listener 재시도 정책 유지🔥 리뷰 요청 사항
REQUIRES_NEW트랜잭션에 참여하여 이벤트 단위 원자성이 유지되는지✅ 체크리스트
📎 참고 사항
StatisticsAggregationServiceTest에서 사용자 누적 통계, 주간 연습 통계, 주간 스킬 통계의 기존 집계 결과를 검증합니다.StatisticsAggregationOrchestrationTest에서 연주 완료 및 분석 완료 이벤트별 집계 대상과 호출 순서를 검증합니다.StatisticsEventListenerRetryTest에서DataIntegrityViolationException발생 시 최대 3회 재시도 및 Recover 동작을 검증합니다.Summary by CodeRabbit
새로운 기능
테스트