Skip to content

fix: 오늘 날짜 코스를 조회 시점에 IN_PROGRESS로 지연 승격 - #67

Merged
yxpjseo merged 2 commits into
developfrom
fix/today
Aug 12, 2026
Merged

yxpjseo merged 2 commits into
developfrom
fix/today

Conversation

@yxpjseo

@yxpjseo yxpjseo commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

📌 관련 이슈

  • close #00

🔎 What is this PR?

투데이 코스 조회와 홈 진행중 코스가 오늘 날짜 코스를 인식하지 못하던 문제를 수정했습니다.
코스 상태가 PLANNING → IN_PROGRESS로 전이되는 로직이 없어 발생한 이슈로, 조회 시점 지연 승격 방식으로 해결했습니다.

✨ Changes

문제

  • 코스는 생성 시 PLANNING 상태이고, 상태 전이는 종료(COMPLETED) 하나뿐이라 어떤 코스도 IN_PROGRESS가 되지 않았습니다.
  • 투데이 코스 조회(GET /courses/today)는 IN_PROGRESS만 찾으므로 항상 todayCourse: null 응답.
  • 홈(GET /courses)의 진행중 목록·배너도 IN_PROGRESS 상태에 의존해, 오늘 코스를 "진행중"이 아닌 "곧 다가오는 일정"으로 잘못 표시.

해결 — 조회 시점 지연 승격

  • Course.start() 추가: PLANNING → IN_PROGRESS 전이.
  • 공용 헬퍼 TodayCoursePromoter.promoteDueCourses(userId, today) 추가: courseDate가 오늘인 내 PLANNING 코스를 IN_PROGRESS로 승격.
  • 홈(getCourses)·투데이(getTodayCourse) 두 조회 진입점에서 동일 규칙으로 승격 후 조회하도록 배선. 어느 화면을 먼저 열어도 일관되게 동작.
  • getCourses는 쓰기 트랜잭션으로 전환(@transactional), 승격 로직이 호출 측 트랜잭션에 합류.
  • CourseRepository의 투데이 조회 쿼리를 단일 상태 → 상태 컬렉션(in) 기반으로 변경.

참고

  • 종료는 기존대로 사용자가 종료 버튼(completeCourse, IN_PROGRESS일 때만 가능)으로 수행하므로 자동 완료 로직은 추가하지 않았습니다.
  • 별도 스케줄러 없이 조회 시점에 전환하는 방식이라, 이 API를 호출하지 않은 코스는 승격되지 않습니다(현재 요구사항 범위 내 정상 동작).

📷 Result


💬 To. Reviewer

  • 승격을 "조회 시점 지연 전환(A안)"으로 구현했습니다. 스케줄러(자정 일괄 전환) 대신 이 방식을 택한 이유는 잡 미실행 시 그날 종일 비는 리스크를 피하기 위함인데, 방향이 괜찮은지 확인 부탁드립니다.
  • getCourses가 조회 API임에도, 상태 변경을 위해 쓰기 트랜잭션으로 수정한 점 확인 부탁드립니다.

✅ 체크 리스트

  • base 브랜치(develop 또는 main) 최신 상태 pull 및 충돌 확인 완료
  • Reviewers 설정
  • Assignees 설정
  • Labels 설정

PLANNING -> IN_PROGRESS 전이 로직이 없어 투데이 코스 조회가 항상
비어 있고, 홈의 진행중 목록/배너도 오늘 코스를 인식하지 못하던 문제 수정.

- Course.start()로 PLANNING -> IN_PROGRESS 전이 추가
- 오늘 날짜 코스를 승격시키는 공용 헬퍼 TodayCoursePromoter 추가
- 홈(getCourses)/투데이(getTodayCourse) 조회 진입 시 동일 규칙으로 승격
- CourseRepository 쿼리를 상태 컬렉션(in) 기반으로 변경
@yxpjseo yxpjseo self-assigned this Aug 12, 2026
@yxpjseo yxpjseo added the 🐛 fix develop 브랜치에서 발생한 버그를 수정하는 작업 label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The course flow now promotes today’s planning courses to IN_PROGRESS before retrieval. The repository accepts multiple statuses, and both course retrieval services invoke the promotion logic in write transactions.

Changes

Course promotion and retrieval

Layer / File(s) Summary
Course lifecycle and status query
src/main/java/com/daytodo/domain/course/entity/Course.java, src/main/java/com/daytodo/domain/course/repository/CourseRepository.java, src/test/java/com/daytodo/domain/course/repository/CourseQueryValidationTest.java
Course.start() sets the course status to IN_PROGRESS. The repository query now accepts multiple statuses with IN, and validation uses planning and in-progress statuses.
Due course promotion
src/main/java/com/daytodo/domain/course/service/TodayCoursePromoter.java
TodayCoursePromoter finds today’s planning courses for a user and starts each course within a transaction.
Retrieval service integration
src/main/java/com/daytodo/domain/course/service/CourseService.java, src/main/java/com/daytodo/domain/course/service/TodayCourseService.java, src/test/java/com/daytodo/domain/course/service/CourseServiceTest.java
Both retrieval services promote due courses before querying. CourseServiceTest supplies the promoter mock.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CourseService
  participant TodayCoursePromoter
  participant CourseRepository
  participant Course
  Client->>CourseService: request courses
  CourseService->>TodayCoursePromoter: promoteDueCourses(userId, today)
  TodayCoursePromoter->>CourseRepository: find today’s PLANNING courses
  CourseRepository-->>TodayCoursePromoter: return joined courses
  TodayCoursePromoter->>Course: start()
  Course-->>TodayCoursePromoter: set IN_PROGRESS
  CourseService->>CourseRepository: retrieve courses
  CourseRepository-->>CourseService: return course data
  CourseService-->>Client: return courses
Loading

Possibly related PRs

Suggested reviewers: kwonwnsduf, hyeoniss

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: delayed promotion of courses dated today to IN_PROGRESS during lookup.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/today

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/java/com/daytodo/domain/course/service/CourseServiceTest.java (1)

73-92: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Verify the promotion call in a getCourses test.

The mock only satisfies constructor injection. Add an assertion that getCourses calls todayCoursePromoter.promoteDueCourses(1L, TODAY) before it loads in-progress courses. This protects the new home-flow integration from regression.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/com/daytodo/domain/course/service/CourseServiceTest.java`
around lines 73 - 92, Update a getCourses test in CourseServiceTest to verify
todayCoursePromoter.promoteDueCourses(1L, TODAY) is invoked before loading
in-progress courses, using the existing todayCoursePromoter mock and appropriate
interaction-order verification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/daytodo/domain/course/service/TodayCourseService.java`:
- Around line 46-54: Update TodayCourseService to inject the shared Clock used
by CourseService, then replace the LocalDate.now() call in getTodayCourse with
LocalDate.now(clock) so promotion and course lookup use the same business date.

---

Nitpick comments:
In `@src/test/java/com/daytodo/domain/course/service/CourseServiceTest.java`:
- Around line 73-92: Update a getCourses test in CourseServiceTest to verify
todayCoursePromoter.promoteDueCourses(1L, TODAY) is invoked before loading
in-progress courses, using the existing todayCoursePromoter mock and appropriate
interaction-order verification.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5cf40f33-f665-43d1-88e0-e301e9796ae1

📥 Commits

Reviewing files that changed from the base of the PR and between 1ee6dd4 and d35351d.

📒 Files selected for processing (7)
  • src/main/java/com/daytodo/domain/course/entity/Course.java
  • src/main/java/com/daytodo/domain/course/repository/CourseRepository.java
  • src/main/java/com/daytodo/domain/course/service/CourseService.java
  • src/main/java/com/daytodo/domain/course/service/TodayCoursePromoter.java
  • src/main/java/com/daytodo/domain/course/service/TodayCourseService.java
  • src/test/java/com/daytodo/domain/course/repository/CourseQueryValidationTest.java
  • src/test/java/com/daytodo/domain/course/service/CourseServiceTest.java

@yxpjseo
yxpjseo marked this pull request as draft August 12, 2026 04:26
@yxpjseo
yxpjseo marked this pull request as ready for review August 12, 2026 04:30

@nariming nariming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

수고하셨습니다!

@yxpjseo
yxpjseo merged commit f55b7da into develop Aug 12, 2026
1 check passed
@yxpjseo
yxpjseo deleted the fix/today branch August 12, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 fix develop 브랜치에서 발생한 버그를 수정하는 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants