Skip to content

perf: 월 범위 세션 선필터링으로 월간 통계 쿼리 성능 개선#68

Merged
kon28289 merged 1 commit intodevfrom
perf/statistics
Feb 7, 2026
Merged

perf: 월 범위 세션 선필터링으로 월간 통계 쿼리 성능 개선#68
kon28289 merged 1 commit intodevfrom
perf/statistics

Conversation

@kon28289
Copy link
Contributor

@kon28289 kon28289 commented Feb 4, 2026

🚀 1. 개요

  • 월간 통계의 쿼리 구조를 변경합니다.

📝 2. 주요 변경 사항

  • 기존에는 사용자 아이디에 해당하는 모든 공부세션을 조회하여 불필요한 세션들이 함께 조회되었지만, 해당 월과 겹치는 공부세션을 조회하도록 쿼리를 개선합니다.

📸 3. 스크린샷 (API 테스트 결과)

Summary by CodeRabbit

릴리스 노트

  • Refactor
    • 월간 통계 계산 시 완료된 학습 세션만 반영되도록 계산 로직이 변경되었습니다.
    • 일일 통계 집계 방식이 개선되어 더 정확한 월간 데이터를 제공합니다.

@kon28289 kon28289 self-assigned this Feb 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

요약

월간 통계 조회 쿼리가 완료된 세션을 사전 필터링하고 일별 집계 로직을 개선하는 방식으로 재작성되었습니다. 새로운 버전은 필터링된 세션 CTE를 추가하여 대상 월 내 완료된 세션을 사전 필터링하고, 그 집합에서 일별 값을 집계합니다.

변경 사항

Cohort / File(s) 요약
월간 통계 저장소 쿼리 최적화
src/main/java/com/gpt/geumpumtabackend/statistics/repository/StatisticsRepository.java
getMonthlyStatistics 쿼리를 재작성하여 filtered_sessions CTE를 통한 사전 필터링, 일별 집계 로직 개선, COALESCE를 LEAST로 변경하여 진행 중인 세션을 제외하고 월 내 완료된 세션만으로 통계를 계산하도록 수정.

예상 코드 리뷰 노력

🎯 4 (Complex) | ⏱️ ~45분

관련된 가능성이 있는 PR

제안 라벨

enhancement

제안 검토자

  • Juhye0k

시 (poem) 🐰

필터링된 세션들이 모여
완성된 공부만 세어가고
날마다의 기록이 정확해지니
통계는 더욱 빛나는구나 ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive PR 설명이 템플릿의 주요 섹션을 포함하고 있으나, API 테스트 결과 스크린샷이 누락되어 있습니다. 개요와 주요 변경 사항은 적절히 작성되었습니다. 스크린샷 섹션에 실제 API 테스트 결과 이미지를 추가하여 변경 사항의 영향을 시각적으로 검증하십시오.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경 사항의 핵심을 명확하게 요약하고 있습니다. 월간 통계 쿼리 성능 개선 및 세션 선필터링이라는 주요 변경점을 정확히 설명합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch perf/statistics

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@kon28289 kon28289 requested a review from Juhye0k February 4, 2026 04:52
Copy link
Contributor

@Juhye0k Juhye0k left a comment

Choose a reason for hiding this comment

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

고생하셨습니다

@kon28289 kon28289 merged commit 861480c into dev Feb 7, 2026
4 checks passed
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.

2 participants