-
Notifications
You must be signed in to change notification settings - Fork 4
중복된 formatStudyTime 함수 유틸화 #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
중복된 formatStudyTime 함수 유틸화 #160
Conversation
Summary by CodeRabbit
진행 상황여러 페이지 컴포넌트에서 로컬로 정의된 시간 포맷팅 함수를 공유 유틸리티 함수로 대체하고, 새로운 포맷팅 유틸리티 파일을 추가했습니다. 변경 사항
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🧰 Additional context used🧬 Code graph analysis (4)src/pages/Admin/ReportList/components/GroupReportListView.tsx (1)
src/pages/ReportList/Page.tsx (1)
src/pages/Admin/ReportList/Page.tsx (1)
src/pages/ReportDetail/Page.tsx (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (6)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extracts a duplicated formatStudyTime function into a reusable utility function formatTimeToHoursAndMinutes. The function converts minutes into a Korean-formatted time string (e.g., "3시간 45분").
Key changes:
- Created a new utility function
formatTimeToHoursAndMinutesinsrc/utils/formatTimeToHoursAndMinutes.ts - Removed duplicate implementations from 4 files and replaced them with imports of the new utility
- Improved function naming from domain-specific
formatStudyTimeto more genericformatTimeToHoursAndMinutes
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/formatTimeToHoursAndMinutes.ts | New utility file containing the extracted time formatting function |
| src/pages/ReportList/Page.tsx | Removed local function, imported and used the new utility |
| src/pages/ReportDetail/Page.tsx | Removed local function, imported and used the new utility |
| src/pages/Admin/ReportList/components/GroupReportListView.tsx | Removed local function, imported and used the new utility |
| src/pages/Admin/ReportList/Page.tsx | Removed local function, imported and used the new utility |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| export function formatTimeToHoursAndMinutes(minutes: number) { | ||
| const hours = Math.floor(minutes / 60); | ||
| const mins = minutes % 60; | ||
| return `${hours}시간 ${mins}분`; | ||
| } |
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function does not validate input. Consider adding a guard clause to handle negative numbers or non-integer values, e.g., if (minutes < 0 || !Number.isFinite(minutes)) throw new Error('Invalid minutes value');
| @@ -0,0 +1,5 @@ | |||
| export function formatTimeToHoursAndMinutes(minutes: number) { | |||
Copilot
AI
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add JSDoc documentation to describe the function's purpose, parameter, and return value. For example: /** Formats minutes into Korean time string format (e.g., '3시간 45분') */
|
@minzziPark 그리고 0시간 32분 처럼 시간이 0일 때도 나타나는 것이 의도한 것인지 질문을 주셨는데, 감사합니다. |
작업 사항
중복으로 사용되던
formatStudyTime함수를 별도의 유틸 함수로 분리했습니다.이 함수는
minute을 입력받아00시간 00분형식의 문자열을 반환합니다.기존에는 아래 네 파일에서 동일한 로직이 중복으로 정의되어 있었습니다.
중복 코드를 제거하고 재사용성을 높이기 위해 공통 유틸로 분리했습니다.
Naming
기존 함수명
formatStudyTime은 반환 형태가 명확하지 않고,Study라는 도메인 단어가 포함되어 있어 범용적인 활용이 어렵다고 판단했습니다.이에 따라 함수명을 아래와 같이 변경했습니다.
formatTimeToHoursAndMinutes관련 이슈
시간이나 분이 0인 경우는 생략되지 않고 보여집니다. (ex. 0시간 32분, 3시간 0분)
0일때 보여지는 것은 의도된건지 궁금합니다. @ohinhyuk
Copilot
Please review this PR as if you were a senior developer and provide constructive feedback on code quality, structure, and naming.
close #157