Skip to content

Comments

[FIX/#297] 라운드 연장 코드 수정#298

Merged
Hminkyung merged 1 commit intodevelopfrom
fix/#297-round-no-ing
Feb 7, 2026
Merged

[FIX/#297] 라운드 연장 코드 수정#298
Hminkyung merged 1 commit intodevelopfrom
fix/#297-round-no-ing

Conversation

@Hminkyung
Copy link
Contributor

@Hminkyung Hminkyung commented Feb 7, 2026

#️⃣ 연관된 이슈

관련된 이슈 번호를 적어주세요.
Close #297

✨ 작업 내용 (Summary)

이번 PR에서 작업한 내용을 간략히 설명해주세요. (이미지 첨부 가능)
라운드 연장 처리가 제대로 작동하지 않은 이슈가 발생했습니다
3일전이 아닌 2일전으로 처리가 되어 알림이 발생하고 다음날로 처리가 된 이슈였습니다


✅ 변경 사항 체크리스트

다음 항목들을 확인하고 체크해주세요.

  • 코드에 영향이 있는 모든 부분에 대한 테스트를 작성하고 실행했나요?
  • 문서를 작성하거나 수정했나요? (필요한 경우)
  • 중요한 변경 사항이 팀에 공유되었나요?

🧪 테스트 결과

코드 변경에 대해 테스트를 수행한 결과를 요약해주세요.

  • 테스트 환경: (예: 로컬, 개발 서버 등) 로컬
  • 테스트 방법: (예: Postman, 단위 테스트, 수동 기능 테스트 등) 단위테스트
  • 결과 요약: (예: 모든 테스트 통과, 새로운 테스트 케이스 3개 추가 완료) 모든 테스트 완료

📸 스크린샷

관련된 스크린샷 또는 GIF가 있다면 여기에 첨부해주세요.

스크린샷 2026-02-07 130359

💬 리뷰 요구사항

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요.


📎 참고 자료

관련 문서, 레퍼런스 링크 등이 있다면 여기에 첨부해주세요.

Summary by CodeRabbit

버그 수정

  • 의사결정 기간이 개선되었습니다.
    • 의사결정 가능 기간이 1일에서 2일로 확장되었습니다.
    • 라운드 종료 예정일 3일 전부터 2일 전까지 더 긴 기간 동안 결정을 내릴 수 있습니다.
    • 사용자는 이제 더 많은 시간을 가지고 신중한 선택을 할 수 있습니다.

@Hminkyung Hminkyung self-assigned this Feb 7, 2026
@Hminkyung Hminkyung added 🐞 bug 버그 이슈 ✔️ test 테스트 민경 labels Feb 7, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

📝 Walkthrough

개요

라운드 연장 결정 가능 기간을 D-2..D-1에서 D-3..D-2로 확대하는 유효성 검사 로직 수정입니다. 이는 알림 당일에 연장이 불가능한 버그를 해결하며, 서비스와 테스트 코드가 함께 업데이트되었습니다.

변경사항

코호트 / 파일 요약
결정 기간 로직 수정
src/main/java/com/hrr/backend/domain/round/service/RoundDecisionServiceImpl.java
validateDecisionPeriod() 메서드에서 결정 가능 기간 계산 수정: 개시일 D-2→D-3, 종료일 D-1→D-2로 변경. 유효 기간을 1일에서 2일로 확대. 조건문 로직 반전으로 D-2 시점 포함(D-2 이후 접근 차단). 인라인 주석 업데이트.
확대된 결정 기간 테스트
src/test/java/com/hrr/backend/domain/round/RoundFlowUnitTest.java
D-4~D-1 범위의 새로운 결정 기간 테스트 추가. 각 테스트에서 라운드 레코드 업데이트, 이벤트 발행 검증. LocalDate.now() 기준 상대 시간 로직으로 조정. 임포트 정리 및 테스트 메서드명 개선.

코드 리뷰 노력 예측

🎯 3 (중간 복잡도) | ⏱️ ~25분

관련 가능성 있는 PR

🌅 D-3에 문이 열리니
D-2까지 연장할 수 있다네
알림 받은 그 당일도
더 이상 못하는 일은 없고 ✨
버그는 사라지고 기쁨만 남는다


💡 개선 제안

테스트 커버리지 관점에서의 고려사항:

  • 현재 테스트는 의도적인 성공/실패 경로를 잘 검증하고 있습니다. 다만 엣지 케이스로서 타임존(timezone) 경계 상황 (자정 전후의 LocalDate.now() 변경)에서의 동작도 추가로 검토하면 좋습니다.

코드 품질 개선:

  • validateDecisionPeriod() 메서드 내 하드코딩된 일수 상수(3, 2)를 상수로 선언하면 향후 유지보수성이 높아집니다:
    private static final long DECISION_OPEN_DAYS_BEFORE_END = 3L;
    private static final long DECISION_CLOSE_DAYS_BEFORE_END = 2L;
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 라운드 연장 코드 수정이라는 핵심 변경사항을 명확하게 반영하며, 이슈 번호 #297과 함께 변경사항의 주요 목적을 잘 설명합니다.
Linked Issues check ✅ Passed 결정 기간 윈도우를 D-2 에서 D-3 로 조정하여, 라운드 연장 알림이 의도한 일정에 정확히 처리되도록 수정했으며 변경사항이 이슈 #297의 요구사항을 충족합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 라운드 연장 로직 수정과 관련 테스트 재작성에 한정되어 있으며, 이슈 #297의 범위를 벗어나는 변경사항은 없습니다.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/#297-round-no-ing

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

@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: 0

Caution

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

⚠️ Outside diff range comments (1)
src/test/java/com/hrr/backend/domain/round/RoundFlowUnitTest.java (1)

395-436: ⚠️ Potential issue | 🟡 Minor

드랍 테스트 — UNDECIDED 케이스 누락 확인 필요

테스트 이름은 dropsStopAndUndecided이지만, 실제 테스트 데이터에는 STOP만 포함되어 있고 UNDECIDED RoundRecord가 없습니다. UNDECIDED도 드랍 대상이라면 테스트에 추가하여 이름과 검증 범위를 일치시켜야 합니다.

💡 UNDECIDED 케이스 추가 예시
         RoundRecord rrStop = mock(RoundRecord.class);
         when(rrStop.getNextRoundIntent()).thenReturn(NextRoundIntent.STOP);
+        RoundRecord rrUndecided = mock(RoundRecord.class);
+        when(rrUndecided.getNextRoundIntent()).thenReturn(NextRoundIntent.UNDECIDED);

         UserChallenge ucStop = mock(UserChallenge.class);
         when(rrStop.getUserChallenge()).thenReturn(ucStop);
         when(ucStop.getStatus()).thenReturn(ChallengeJoinStatus.JOINED);

+        UserChallenge ucUndecided = mock(UserChallenge.class);
+        when(rrUndecided.getUserChallenge()).thenReturn(ucUndecided);
+        when(ucUndecided.getStatus()).thenReturn(ChallengeJoinStatus.JOINED);
+
         when(roundRecordRepository.findAllByRoundWithUserAndSetting(endedRound, ChallengeJoinStatus.JOINED))
-                .thenReturn(List.of(rrContinue, rrStop));
+                .thenReturn(List.of(rrContinue, rrStop, rrUndecided));

         // when
         roundDropService.dropNonContinuersAt(endDate);

         // then
         verify(ucStop).updateStatus(ChallengeJoinStatus.DROPPED);
+        verify(ucUndecided).updateStatus(ChallengeJoinStatus.DROPPED);
-        verify(challengeRepository, times(1)).decreaseCurrentParticipantCount(999L);
+        verify(challengeRepository, times(2)).decreaseCurrentParticipantCount(999L);
🧹 Nitpick comments (3)
src/main/java/com/hrr/backend/domain/round/service/RoundDecisionServiceImpl.java (1)

94-120: 결정 기간 로직 변경 — 핵심 수정이 올바르게 적용되었습니다 👍

D-3 ~ D-2 윈도우로의 변경이 PR 목적에 부합하며, isBefore/isAfter 조합으로 양 끝 날짜를 포함(inclusive)하는 처리가 정확합니다.

다만, Line 116의 주석에서 !today.isBefore(decisionCloseDate) → today.isAfter(decisionCloseDate) 라고 동치(equivalence)로 설명하고 있는데, 이 둘은 동치가 아닙니다.

  • !isBefore(X) = X 이후 또는 같은 날 (>=)
  • isAfter(X) = X 이후 (strictly >)

실제 코드는 isAfter를 사용하므로 D-2 당일을 포함시키는 의도에 부합하지만, 주석이 잘못된 동치 관계를 서술하고 있어 향후 유지보수 시 혼란을 줄 수 있습니다. 주석을 수정하는 것을 권장합니다.

📝 주석 수정 제안
-        // D-2를 넘어가면 기간 만료 (D-2 23:59까지 가능)
-        // !today.isBefore(decisionCloseDate) → today.isAfter(decisionCloseDate)
-        // 이유: D-2 당일까지 포함시키기 위함
+        // D-2를 넘어가면 기간 만료 (D-2 당일까지 가능)
+        // isAfter(decisionCloseDate) → D-2 당일은 통과, D-2 다음 날부터 차단
         if (today.isAfter(decisionCloseDate)) {
src/test/java/com/hrr/backend/domain/round/RoundFlowUnitTest.java (2)

72-266: 테스트 경계값 검증이 잘 구성되어 있습니다 🎯

D-4(실패), D-3(성공), D-2(성공), D-1(실패) — 네 가지 경계 시나리오를 빠짐없이 커버하고 있어 좋습니다.

한 가지 주의점: 테스트에서는 LocalDate.now()를 사용하지만, 프로덕션 코드(RoundDecisionServiceImpl)에서는 LocalDate.now(ZoneId.of("Asia/Seoul"))을 사용합니다. UTC 기준 자정 전후에 CI가 실행되면 두 값이 다른 날짜를 반환할 수 있어 테스트가 간헐적으로(flaky) 실패할 수 있습니다.

권장 개선: ClockRoundDecisionServiceImpl에 주입하여 테스트에서 고정된 시각을 사용하면 이 문제를 근본적으로 해결할 수 있습니다. (Java Clock 공식 문서 참고)

💡 Clock 주입 예시 (프로덕션 코드)
 `@Service`
 `@RequiredArgsConstructor`
 public class RoundDecisionServiceImpl implements RoundDecisionService {
+    private final Clock clock;
     // ...
     private void validateDecisionPeriod(Round currentRound) {
-        LocalDate today = LocalDate.now(ZoneId.of("Asia/Seoul"));
+        LocalDate today = LocalDate.now(clock);

Bean 등록:

`@Bean`
public Clock clock() {
    return Clock.system(ZoneId.of("Asia/Seoul"));
}

테스트에서:

Clock fixedClock = Clock.fixed(
    LocalDate.of(2026, 2, 7).atStartOfDay(ZoneId.of("Asia/Seoul")).toInstant(),
    ZoneId.of("Asia/Seoul")
);

222-266: realScenario_day18_afterNotificationD_minus_3_shouldSucceed와 사실상 동일합니다

두 테스트 모두 endDate = today.plusDays(3), intent = CONTINUE로 동일한 조건을 검증합니다. 테스트 이름만 다르고 로직이 중복되어 유지보수 부담이 늘어납니다.

차별화가 필요하다면 (예: 특정 시각 기반 시나리오), 위에서 제안한 Clock 주입 후 시각을 고정하여 "오전 9시 알림 직후" 같은 시간 조건을 실제로 반영하는 것이 좋겠습니다. 그렇지 않다면 하나로 통합하는 것을 고려해 주세요.

@Hminkyung Hminkyung requested a review from yc3697 February 7, 2026 04:29
Copy link
Contributor

@yc3697 yc3697 left a comment

Choose a reason for hiding this comment

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

확인했습니다~

@Hminkyung Hminkyung merged commit 7553fed into develop Feb 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug 버그 이슈 ✔️ test 테스트 민경

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 챌린지 연장 오류 수정

2 participants