Skip to content

refactor : 공부시간 계산 로직 수정 및 모니터링 라이브러리#46

Merged
Juhye0k merged 4 commits intodevfrom
ip
Dec 2, 2025
Merged

refactor : 공부시간 계산 로직 수정 및 모니터링 라이브러리#46
Juhye0k merged 4 commits intodevfrom
ip

Conversation

@Juhye0k
Copy link
Copy Markdown
Contributor

@Juhye0k Juhye0k commented Dec 2, 2025

🚀 1. 개요

랭킹 집계 쿼리의 시간 계산 정밀도를 보정하는 작업을 포함합니다.

📝 2. 주요 변경 사항

공부 시간 계산 로직 정밀도 보정 (StudySessionRepository)

  • 문제점: 기존 로직은 TIMESTAMPDIFF(SECOND, ...)로 초 단위 차이를 구한 뒤 1000을 곱하는 방식이라, 1초 미만의 시간(밀리초)이 소실되는 문제가 있었습니다.
  • 해결: TIMESTAMPDIFF(MICROSECOND, ...)로 마이크로초 단위 차이를 구한 뒤 1000으로 나누는 방식으로 변경하여 밀리초 단위의 정밀도를 확보했습니다.
  • 적용 대상:
    • calculateCurrentPeriodRanking (현재 기간 개인 랭킹)
    • calculateFinalizedPeriodRanking (지난 기간 개인 랭킹)
    • calculateCurrentDepartmentRanking (현재 기간 학과 랭킹)
    • calculateFinalizedDepartmentRanking (지난 기간 학과 랭킹)

Summary by CodeRabbit

릴리스 노트

  • Bug Fixes

    • 학습 세션 순위 계산과 부서별 순위 집계에서 시간 측정 정밀도가 향상되어, 사용자들이 더욱 정확하고 신뢰할 수 있는 순위 정보를 확인할 수 있게 되었습니다.
  • Chores

    • 내부 라이브러리 정리로 일부 인증/암호화 관련 패키지가 제거되어 빌드가 경량화되었습니다.
    • 시스템 상태 모니터링 및 성능 메트릭 추적 기능이 강화되어 서비스 안정성이 개선되었습니다.

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

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

coderabbitai bot commented Dec 2, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

build.gradle에서 com.nimbusds:nimbus-jose-jwt:9.37.4 의존성을 제거했고, StudySessionRepository.java의 여러 네이티브 SQL에서 TIMESTAMPDIFF 단위를 SECOND에서 MICROSECOND로 변경하고 밀리초 정규화 산술을 조정했습니다.

Changes

응집군 / 파일(들) 변경 요약
빌드/의존성 변경
build.gradle
com.nimbusds:nimbus-jose-jwt:9.37.4 의존성 라인 제거
시간 정밀도 수정
src/main/java/com/gpt/geumpumtabackend/study/repository/StudySessionRepository.java
여러 네이티브 SQL 쿼리에서 TIMESTAMPDIFF(SECOND, ...)TIMESTAMPDIFF(MICROSECOND, ...)로 변경하고, 기존 *1000 곱셈을 /1000으로 바꿔 밀리초 단위로 정규화하는 산술 조정 수행 (calculateCurrentPeriodRanking, calculateFinalizedPeriodRanking, calculateCurrentDepartmentRanking, calculateFinalizedDepartmentRanking 등 관련 집계 쿼리들)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • 주의할 파일/영역:
    • StudySessionRepository.java의 각 네이티브 쿼리에서 단위 변경이 일관되게 적용되었는지 검증
    • 산술 변경(/1000 vs *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 제목은 공부 시간 계산 로직 수정을 언급하지만, 실제 변경사항에는 Nimbus JOSE JWT 라이브러리 제거도 포함되어 있어 부분적으로만 관련됨.
Description check ✅ Passed PR 설명은 필수 템플릿 섹션(개요, 주요 변경사항)을 포함하지만 스크린샷 섹션이 누락되어 있음.

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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/gpt/geumpumtabackend/study/repository/StudySessionRepository.java (1)

100-109: totalMillis 계산에서 /1000 나눗셈이 누락되었습니다.

totalMillis 계산 시 TIMESTAMPDIFF(MICROSECOND, ...) 결과를 1000으로 나누지 않아 마이크로초가 반환됩니다. 같은 쿼리의 RANK와 ORDER BY, 그리고 다른 모든 랭킹 쿼리들은 /1000을 적용하여 밀리초로 변환하고 있습니다.

이로 인해 totalMillis 값이 예상보다 1000배 크게 반환되어 데이터 불일치가 발생합니다.

               CAST(COALESCE(SUM(
                   TIMESTAMPDIFF(MICROSECOND,
                       GREATEST(s.start_time, :periodStart),
                       CASE
                           WHEN s.end_time IS NULL THEN :periodEnd
                           WHEN s.end_time > :periodEnd THEN :periodEnd
                           ELSE s.end_time
                       END
-                  ) 
+                  ) / 1000
               ), 0) AS SIGNED) as totalMillis,
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d8a884 and 2ac6645.

📒 Files selected for processing (2)
  • build.gradle (1 hunks)
  • src/main/java/com/gpt/geumpumtabackend/study/repository/StudySessionRepository.java (7 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
🔇 Additional comments (3)
src/main/java/com/gpt/geumpumtabackend/study/repository/StudySessionRepository.java (3)

42-87: LGTM!

TIMESTAMPDIFF(MICROSECOND, ...) / 1000 로직이 totalMillis, RANK, ORDER BY에 일관되게 적용되어 밀리초 정밀도가 올바르게 유지됩니다.


143-183: LGTM!

학과 랭킹 쿼리의 모든 시간 계산 로직이 일관되게 MICROSECOND / 1000을 사용하여 밀리초를 정확히 반환합니다.


185-225: LGTM!

확정된 학과 랭킹 쿼리도 모든 시간 계산에서 일관된 변환 로직을 사용하고 있습니다.

@Juhye0k Juhye0k changed the base branch from main to dev December 2, 2025 04:10
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