Repository navigation
[feat] #34 - 타이머 완료/종료 - #68
Conversation
…to feat/#34-timer-stop-complete
|
Warning Review limit reached
Next review available in: 41 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Walkthrough타이머 완료/종료 기능을 위해 TimerFinishResponse DTO, TimerRecord.finish 상태 전이 메서드, TIMER_ALREADY_FINISHED 에러 코드, TIMER_COMPLETED/TIMER_STOPPED 성공 코드가 추가됐다. TimerService에 completeTimer/stopTimer 및 공통 finishTimer 로직(경과 시간 계산, TodoInstance 처리)이 구현됐고, TimerController에 PATCH /timers/{timerId}/complete, /stop 엔드포인트가 추가됐다. Changes타이머 완료/종료 기능
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant TimerController
participant TimerService
participant TimerRecord
participant TodoInstance
Client->>TimerController: PATCH /timers/{timerId}/complete or /stop
TimerController->>TimerService: completeTimer/stopTimer(userId, timerId)
TimerService->>TimerService: finishTimer(targetStatus)
TimerService->>TimerRecord: finish(status, now, actualSeconds, aiFeedback)
TimerService->>TodoInstance: stopTimer() / markCompleted()
TimerService-->>TimerController: TimerFinishResponse
TimerController-->>Client: BaseResponse(TIMER_COMPLETED/TIMER_STOPPED)
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
|
|
||
| @Transactional | ||
| public TimerFinishResponse completeTimer(Long userId, Long timerId) { | ||
| return finishTimer(userId, timerId, TimerStatus.COMPLETED); |
There was a problem hiding this comment.
완료와 수동 종료의 공통 로직을 finishTimer()로 묶고 최종 상태만 전달하도록 구성 조은것 같아용
| LocalDateTime now = LocalDateTime.now(); | ||
| int actualSeconds = calculateElapsedSeconds(timerId, now); | ||
|
|
||
| timerRecord.finish(targetStatus, now, actualSeconds, null); |
There was a problem hiding this comment.
P3) RUNNING 상태의 타이머를 완료하거나 종료할 때 활성 TimerSession의 pausedAt은 갱신되지 않는 것 같아용
그러면 TimerRecord는 종료 상태인데 세션은 여전히 활성 상태(pausedAt=null)로 남고 이후 활성 세션 조회나 경과 시간 재계산 시 종료 이후 시간까지 포함될 수 있지 않을까 싶습니당
그래서 타이머 종료 시 활성 세션도 now로 닫아주면 좋을 것 같습니다!
There was a problem hiding this comment.
말씀주신대로 actualSeconds 계산 직후, 활성 세션이 있으면 종료 시각(now)으로 pausedAt을 채우도록 수정했습니다!! PAUSED 상태에서 종료하는 경우는 이미 활성 세션이 없는 상태라 별도 처리 없이 자연스럽게 넘어가게 하였습니다!!
감사합니다아:)
laura-jung
left a comment
There was a problem hiding this comment.
아주 굳입니다. 응답 코드만 수정하고 머지합니다.
|
|
||
| boolean existsByTodo_IdAndStatusIn(Long todoId, List<TimerStatus> statuses); | ||
|
|
||
| @Lock(LockModeType.PESSIMISTIC_WRITE) |
| TIMER_COMPLETED(HttpStatus.OK, "TIMER_200_3", "타이머가 완료되었습니다."), | ||
| TIMER_STOPPED(HttpStatus.OK, "TIMER_200_4", "타이머가 종료되었습니다."); |
There was a problem hiding this comment.
p3) 저희 에러코드에는 넘버링 안하기로 해서 뒤에 _3, _4 없애도 될 것 같습니다
관련 이슈 🛠
작업 내용 요약 ✏️
투두 타이머의 완료(자동 종료)/종료(수동 종료) API 구현
예상 시간이 모두 경과하여 자동으로 완료되는 경우와, 사용자가 직접 종료하는 경우를 각각 다루며, 두 API 모두 실제 수행 시간을 계산하고 날짜별 TodoInstance의 완료 상태를 갱신합니다.
주요 변경 사항 🛠️
TimerErrorCode,TimerSuccessCode에 완료/종료 관련 코드 추가TimerRecord에finish()도메인 메서드 추가PATCH /timers/{timerId}/complete,PATCH /timers/{timerId}/stopAPI 구현finishTimerprivate 메서드로 묶어 중복 제거TimerFinishResponse공통 응답 DTO 추가 (완료/종료 응답 필드가 동일하여 통합)TodoInstance의timerStatus,completed상태 동기화TodoInstance를 조회하고, 없으면 생성 후stopTimer()+markCompleted()호출TimerCompleteControllerDocs,TimerStopControllerDocs추가하여 Swagger 문서화트러블 슈팅 ⚽️
테스트 결과 📄
PATCH /timers/{timerId}/complete성공 시 200 응답, status=COMPLETED, actualSeconds 정상 계산 확인PATCH /timers/{timerId}/stop성공 시 200 응답, status=STOPPED, actualSeconds 정상 계산 확인스크린샷 📷
PATCH /timers/{timerId}/complete성공 시 200 응답, status=COMPLETED, actualSeconds 정상 계산 확인PATCH /timers/{timerId}/stop성공 시 200 응답, status=STOPPED, actualSeconds 정상 계산 확인완료/종료 후 해당 날짜 TodoInstance의 completed=true, timerStatus=STOPPED 확인 (DB 직접 조회)
존재하지 않는 timerId로 요청 시 404 확인
이미 종료된 타이머에 재요청 시 409 확인
리뷰 요구사항 📢
aiFeedback을 현재null로 반환하고 있으니 참고해주시면 감사하겠습니다 :)📎 참고 자료 (선택)
Summary by CodeRabbit
New Features
Bug Fixes
Chores