Skip to content

Conversation

@Jjiggu
Copy link
Contributor

@Jjiggu Jjiggu commented Jul 29, 2025

작업 요약

  • 사용자가 웨이팅 취소 시 DB에 데이터 저장되도록 변경
  • 입장 시간 처리 updatedAt으로 통일

Issue Link

#174

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 버그 수정

    • 예약 상태 관련 시간 정보가 여러 필드에서 하나의 업데이트 시간(updatedAt) 필드로 통합되어 표시됩니다.
    • 예약 상태 변경 시, 관련 시간 정보가 일관되게 처리됩니다.
  • 리팩터링

    • 예약 상태 및 시간 관리 방식이 단순화되어 관리가 용이해졌습니다.
    • 불필요한 필드와 메서드가 제거되어 코드가 간결해졌습니다.

@Jjiggu Jjiggu self-assigned this Jul 29, 2025
@Jjiggu Jjiggu added the refactor 리팩토링 label Jul 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 29, 2025

Caution

Review failed

The pull request is closed.

"""

Walkthrough

여러 DTO, Entity, Service 클래스에서 예약 상태 변경과 관련된 타임스탬프 필드(calledAt, confirmedAt, cancelledAt)가 하나의 updatedAt 필드로 통합되었습니다. 이에 따라 상태 변경 메서드들도 markUpdated로 일원화되었으며, 관련 DTO 및 서비스 로직이 이에 맞게 수정되었습니다.

Changes

Cohort / File(s) Change Summary
EntryStatusResponseDto 단순화
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/dto/EntryStatusResponseDto.java
여러 타임스탬프 필드(calledAt, confirmedAt, cancelledAt, score)를 제거하고, updatedAt 하나로 통합. 팩토리 메서드도 이에 맞게 변경.
ReservationService의 상태 변경 로직 일원화
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java
예약 상태 변경 시 여러 메서드 대신 markUpdated만 호출하도록 변경. Redis에서 calledAt 읽기 및 score 사용 코드 제거.
예약 대기 취소 로직 보강
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java
대기 취소 시 Redis에서 예약 상세정보를 조회 후, Reservation 엔티티 생성 및 저장 로직 추가. 상태 및 타임스탬프 필드도 통합된 방식 적용.
WaitingUserRedisRepository 포맷팅
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/repository/WaitingUserRedisRepository.java
메서드 내 Redis 연산 전후에 빈 줄 추가. 기능적 변경 없음.
Reservation 엔티티 리팩토링
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/entity/Reservation.java
여러 상태별 타임스탬프 필드와 메서드 삭제, updatedAt 필드 및 markUpdated 메서드로 통합.

Sequence Diagram(s)

sequenceDiagram
    participant AdminAPI
    participant ReservationService
    participant Reservation(Entity)
    participant Redis
    participant DB

    AdminAPI->>ReservationService: updateReservationStatus(reservationId, requestDto, memberDetails)
    ReservationService->>Reservation(Entity): markUpdated(now, newStatus)
    ReservationService->>DB: Save Reservation
    ReservationService->>AdminAPI: 반환 (EntryStatusResponseDto with updatedAt)
Loading
sequenceDiagram
    participant UserAPI
    participant ReservationService
    participant WaitingUserRedisRepository
    participant StoreRepository
    participant Reservation(Entity)
    participant DB

    UserAPI->>ReservationService: cancelWaiting(storeId, user)
    ReservationService->>WaitingUserRedisRepository: 대기 정보 조회 (예약번호, 인원, 대기시각)
    alt 예약번호 없음
        ReservationService-->>UserAPI: 예외 발생
    else 예약번호 있음
        ReservationService->>WaitingUserRedisRepository: removeWaiting(...)
        ReservationService->>StoreRepository: findById(storeId)
        ReservationService->>Reservation(Entity): 예약 엔티티 생성 및 markUpdated(now, CANCELLED)
        ReservationService->>DB: 저장
        ReservationService-->>UserAPI: true/false 반환
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

Suggested labels

enhancement
"""

Suggested reviewers

  • HyemIin

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 665fa6d and b24154c.

📒 Files selected for processing (1)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/repository/WaitingUserRedisRepository.java (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/#174-waiting-refactoring

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot requested a review from HyemIin July 29, 2025 09:02
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: 1

🧹 Nitpick comments (3)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java (1)

117-128: 중복된 유효성 검사 로직

reservationNumber이 null인지 확인하여 예외를 던진 후, removeWaiting 결과를 다시 확인하는 것은 중복된 검증입니다. 이미 예약 정보가 존재함을 확인했으므로 removeWaiting은 항상 true를 반환할 것으로 예상됩니다.

 String reservationNumber = waitingUserRedisRepository.getReservationId(storeId, userId);
 if (reservationNumber == null) {
     throw new IllegalArgumentException("Waiting not found");
 }
 Integer partySize = waitingUserRedisRepository.getPartySize(storeId, userId);
 Long ts = waitingUserRedisRepository.getWaitingTimestamp(storeId, userId);
 
 // 대기열에서 제거 및 결과 반환
-boolean removed = waitingUserRedisRepository.removeWaiting(storeId, userId);
-if (!removed) {
-    throw new IllegalArgumentException("Waiting not found");
-}
+waitingUserRedisRepository.removeWaiting(storeId, userId);
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java (2)

268-279: 중복된 updatedAt 설정

Reservation 빌더에서 updatedAt을 설정한 후(274번 줄), markUpdated 메서드를 호출하여(278번 줄) 다시 설정하고 있습니다.

 Reservation r = Reservation.builder()
     .reservationNumber(reservationNumber)
     .store(storeRepository.getReferenceById(storeId))
     .user(userRepository.getReferenceById(Long.valueOf(userId)))
     .partySize(partySize)
     .requestedAt(requestedAt)
-    .updatedAt(LocalDateTime.now())
+    .status(ReservationStatus.CONFIRMED)
+    .updatedAt(LocalDateTime.now())
     .build();
 
-// 호출 시각 반영
-r.markUpdated(LocalDateTime.now(), ReservationStatus.CONFIRMED);
 Reservation saved = reservationRepository.save(r);

307-317: 중복된 updatedAt 설정

CONFIRMED 처리와 동일하게, 빌더에서 updatedAt을 설정한 후 markUpdated를 다시 호출하는 중복이 있습니다.

 Reservation r = Reservation.builder()
     .reservationNumber(reservationNumber)
     .store(storeRepository.getReferenceById(storeId))
     .user(userRepository.getReferenceById(Long.valueOf(userId)))
     .partySize(partySize)
     .requestedAt(requestedAt)
-    .updatedAt(LocalDateTime.now())
+    .status(ReservationStatus.CANCELLED)
+    .updatedAt(LocalDateTime.now())
     .build();
-
-r.markUpdated(LocalDateTime.now(), ReservationStatus.CANCELLED);
 Reservation saved = reservationRepository.save(r);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e2ed48 and 665fa6d.

📒 Files selected for processing (5)
  • nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/dto/EntryStatusResponseDto.java (2 hunks)
  • nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java (5 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/repository/WaitingUserRedisRepository.java (3 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java (1 hunks)
  • nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/entity/Reservation.java (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/entity/Reservation.java (3)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/dto/ReservationGetResponseDto.java (1)
  • ReservationGetResponseDto (11-44)
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/repository/ReservationRepository.java (1)
  • ReservationRepository (14-23)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/controller/ReservationController.java (1)
  • updateEntry (69-85)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java (1)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/repository/WaitingRedisRepository.java (2)
  • deleteWaiting (57-66)
  • WaitingRedisRepository (16-67)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/dto/EntryStatusResponseDto.java (3)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/dto/ReservationGetResponseDto.java (2)
  • ReservationGetResponseDto (11-44)
  • fromEntity (34-43)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/dto/CallGetResponseDto.java (2)
  • CallGetResponseDto (11-43)
  • fromEntity (33-42)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/dto/CallingWaitingResponseDto.java (1)
  • CallingWaitingResponseDto (10-35)
🔇 Additional comments (4)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/reservation/service/ReservationService.java (1)

130-143: 취소된 예약 정보 저장 구현 확인

예약 취소 시 데이터베이스에 기록을 남기는 구현이 적절하게 추가되었습니다. updatedAt 필드를 사용한 타임스탬프 통합 방식도 PR 목적에 부합합니다.

nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/dto/EntryStatusResponseDto.java (1)

34-35: 타임스탬프 필드 통합 확인

여러 개의 타임스탬프 필드(calledAt, confirmedAt, cancelledAt)를 하나의 updatedAt 필드로 통합한 변경사항이 적절히 반영되었습니다.

Also applies to: 52-52

nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/entity/Reservation.java (1)

52-65: 엔티티 리팩토링 승인

여러 상태별 타임스탬프 필드를 하나의 updatedAt 필드로 통합하고, 상태 업데이트 메서드를 markUpdated로 일원화한 설계가 깔끔합니다. 이는 코드 복잡도를 줄이고 유지보수성을 향상시킵니다.

nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java (1)

246-247: 잘못된 지적: setWaitingCalledAt 메서드는 이미 정의되어 있어 컴파일 오류가 발생하지 않습니다.

  • 경로: nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/repository/WaitingRedisRepository.java
  • 메서드 시그니처:
    public void setWaitingCalledAt(Long storeId, String userId, long timestamp) {
        String key = RedisKeyUtils.buildWaitingCalledAtKeyPrefix() + storeId;
        redisTemplate.opsForHash().put(key, userId, String.valueOf(timestamp));
    }

따라서 해당 코드는 정상 동작하며, 이전 지적은 무시하셔도 됩니다.

Likely an incorrect or invalid review comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants