Skip to content

refactor: 공부 시간 millisecond 보정 #45

Merged
Juhye0k merged 2 commits intomainfrom
dev
Dec 1, 2025
Merged

refactor: 공부 시간 millisecond 보정 #45
Juhye0k merged 2 commits intomainfrom
dev

Conversation

@Juhye0k
Copy link
Copy Markdown
Contributor

@Juhye0k Juhye0k commented Dec 1, 2025

🚀 1. 개요

  • StudySessionRepository 공부 시간 합계 쿼리 시간 계산 방식 변경

📝 2. 주요 변경 사항

  • 기존 로직 : TIMESTAMPDIFF(SECOND, ...)를 사용하여 초 단위로 시간을 구한 뒤 1000을 곱하는 방식이었습니다. 이로 인해 초 단위 이하의 시간은 삭제되어 실제 공부 시간과 오차가 발생하는 문제가 발생합니다.
  • MySQL에서는 millisecond를 지원하지 않기 때문에, microsecond로 차이를 구한 다음, 나누기 1000을 통해 millisecond로 보정합니다.

Summary by CodeRabbit

릴리스 노트

  • 버그 수정

    • 학습 세션 기간 계산의 정밀도를 개선했습니다.
  • 최적화

    • 순위 매김 쿼리에서 시간 차이 계산 방식을 업데이트했습니다.

✏️ Tip: You can customize this high-level summary in your review settings.

@Juhye0k Juhye0k requested a review from kon28289 December 1, 2025 11:20
@Juhye0k Juhye0k self-assigned this Dec 1, 2025
@Juhye0k Juhye0k added the enhancement New feature or request label Dec 1, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

StudySessionRepository의 순위 계산 쿼리에서 시간 차이 계산 방식을 변경했습니다. 기존의 초(SECOND) 단위 계산에서 마이크로초(MICROSECOND) 단위로 변경하고 이에 맞춰 스케일링을 조정했습니다.

Changes

군집 / 파일 변경 요약
기간 계산 정확도 개선
src/main/java/com/gpt/geumpumtabackend/study/repository/StudySessionRepository.java
모든 순위 계산 및 집계 쿼리에서 TIMESTAMPDIFF의 시간 단위를 SECOND에서 MICROSECOND로 변경. 기존의 TIMESTAMPDIFF(SECOND, ...) * 1000에서 TIMESTAMPDIFF(MICROSECOND, ...) / 1000으로 스케일링 조정. 일부 경우 명시적 스케일링 없이 TIMESTAMPDIFF(MICROSECOND, ...)만 사용.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10분

  • 스케일링 로직의 일관성 확인 필요 (일부 쿼리에서 /1000 적용 여부 검토)
  • 마이크로초 단위 변환이 모든 쿼리에 올바르게 적용되었는지 각 순위 계산 함수별 검증 필요
  • 기존 밀리초 기반 로직과의 호환성 및 반올림 오류 가능성 확인

Possibly related PRs

Suggested reviewers

  • kon28289

Poem

🐰 마이크로초의 정밀함으로,

시간의 입자를 담아내고,

순위는 더욱 정확해지네요!

⏱️✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 사항과 일치합니다. 밀리초 보정이라는 변경의 핵심을 명확하게 요약하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿의 필수 섹션을 대부분 충족합니다. 개요와 주요 변경 사항이 상세히 작성되었으나 스크린샷 섹션이 누락되어 있습니다.
✨ 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 dev

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bea253b and a14aee4.

📒 Files selected for processing (1)
  • src/main/java/com/gpt/geumpumtabackend/study/repository/StudySessionRepository.java (8 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-11T11:48:29.664Z
Learnt from: kon28289
Repo: Geumpumta/backend PR: 16
File: src/main/java/com/gpt/geumpumtabackend/study/repository/StudySessionRepository.java:264-287
Timestamp: 2025-11-11T11:48:29.664Z
Learning: In the Geumpumta backend project, study session statistics (daily, weekly, monthly, grass) intentionally exclude in-progress sessions where end_time is NULL. Only completed sessions (with non-null end_time) should be counted in the statistics calculations.

Applied to files:

  • src/main/java/com/gpt/geumpumtabackend/study/repository/StudySessionRepository.java

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.

Copy link
Copy Markdown
Contributor

@kon28289 kon28289 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants