-
Notifications
You must be signed in to change notification settings - Fork 0
feat(Reservation):예약 리스트 조회 로직 개선 #165
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
The head ref may contain hidden characters: "feature/#158_Store\uC608\uC57D\uB9CE\uC740\uC21C\uBC18\uD658\uD0C0\uC785\uAC1C\uC120"
Conversation
WalkthroughReservationController의 getWaitingUsersWithScore 메서드 반환 타입이 구체적인 제네릭 타입에서 와일드카드 타입으로 변경되었습니다. ReservationService에서는 대기 사용자 및 완료된 사용자 조회 로직이 개선되어, 사용자 닉네임 조회, 랜덤 예약 ID 생성, 예약 상태 및 날짜 필터링 등이 추가되었습니다. ReservationRepository에는 예약 상태와 날짜 범위로 예약을 조회하는 새로운 메서드가 추가되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Controller as ReservationController
participant Service as ReservationService
participant Repo as ReservationRepository
participant UserRepo as UserRepository
Controller->>Service: getWaitingUsersWithScore(storeId)
Service->>Repo: findByStore_StoreIdAndUserIdAndRequestedAtBetween(...)
Service->>UserRepo: findById(userId)
Service->>Repo: findAllByStore_StoreIdAndStatusInAndRequestedAtBetween(...)
Service-->>Controller: List<WaitingUserResponse> (ResponseEntity<?>)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Possibly related PRs
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/controller/ReservationController.java(1 hunks)nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java(4 hunks)nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/repository/ReservationRepository.java(1 hunks)
🔇 Additional comments (6)
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/reservation/repository/ReservationRepository.java (2)
22-23: 코드 포맷팅 개선이 잘 되었습니다.메서드 시그니처의 가독성이 향상되었습니다.
25-26: 새로운 쿼리 메서드가 적절히 추가되었습니다.상점 ID, 예약 상태 목록, 날짜 범위로 예약을 조회하는 기능이 Spring Data JPA 명명 규칙에 따라 올바르게 구현되었습니다. 서비스 레이어에서 완료/취소된 예약 조회에 필요한 기능을 제공합니다.
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java (4)
9-10: 새로운 import가 적절히 추가되었습니다.ThreadLocalRandom과 UUID import가 아래 로직에서 사용되는 기능을 위해 올바르게 추가되었습니다.
112-113: 날짜 필터링이 포함된 쿼리 개선이 좋습니다.오늘 날짜 범위로 예약을 조회하는 로직이 추가되어 더 정확한 데이터 조회가 가능해졌습니다.
117-121: 예약이 존재할 때의 데이터 설정이 적절합니다.데이터베이스에서 실제 예약 정보를 가져와서 정확한 값들을 설정하는 로직이 올바르게 구현되었습니다.
141-145: 완료된 예약 조회 로직이 효율적으로 개선되었습니다.새로운 repository 메서드를 사용하여 상태와 날짜 범위로 필터링된 예약만 조회하도록 개선되어 성능과 정확성이 향상되었습니다.
| @Operation(summary = "주점별 전체 대기/호출중 리스트 조회", description = "주점에 대한 대기 리스트 조회(WAITING,CALLING)") | ||
| @ApiResponse(responseCode = "200", description = "주점별 전체 대기 리스트 조회") | ||
| public ResponseEntity<List<WaitingUserResponse>> getWaitingUsersWithScore(@PathVariable Long storeId) { | ||
| public ResponseEntity<?> getWaitingUsersWithScore(@PathVariable Long storeId) { |
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.
🛠️ Refactor suggestion
반환 타입을 구체적으로 유지하는 것을 권장합니다.
ResponseEntity<?>로 변경하면 타입 안전성이 감소하고 API 계약이 불분명해집니다. 메서드가 실제로는 List<WaitingUserResponse>를 반환하므로, 원래의 구체적인 타입 ResponseEntity<List<WaitingUserResponse>>을 유지하는 것이 좋습니다.
-public ResponseEntity<?> getWaitingUsersWithScore(@PathVariable Long storeId) {
+public ResponseEntity<List<WaitingUserResponse>> getWaitingUsersWithScore(@PathVariable Long storeId) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public ResponseEntity<?> getWaitingUsersWithScore(@PathVariable Long storeId) { | |
| public ResponseEntity<List<WaitingUserResponse>> getWaitingUsersWithScore(@PathVariable Long storeId) { |
🤖 Prompt for AI Agents
In
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/controller/ReservationController.java
at line 39, the method return type is declared as ResponseEntity<?> which
reduces type safety and obscures the API contract. Change the return type to
ResponseEntity<List<WaitingUserResponse>> to maintain type specificity and
clarity about the response content.
| @Transactional(readOnly = true) | ||
| public List<WaitingUserResponse> getAllWaitingUserDetails(Long storeId) { | ||
| List<ZSetOperations.TypedTuple<String>> waitingList = waitingRedisRepository.getAllWaitingWithScore(storeId); | ||
| System.out.println(waitingList); |
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.
🛠️ Refactor suggestion
디버그 출력문을 제거해주세요.
프로덕션 코드에서 System.out.println은 제거되어야 합니다. 로깅이 필요하다면 적절한 로거를 사용하세요.
-System.out.println(waitingList);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| System.out.println(waitingList); |
🤖 Prompt for AI Agents
In
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java
at line 95, remove the System.out.println statement used for debugging. If
logging is necessary, replace it with a proper logger call using the project's
logging framework instead of direct standard output.
| String userName = userRepository.getReferenceById(Long.valueOf(userId)).getNickname(); | ||
| LocalDateTime createdAt = LocalDateTime.now(); | ||
| String reservationId = String.valueOf( | ||
| ThreadLocalRandom.current().nextInt(1, 100)); | ||
|
|
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.
예약 ID 생성 로직에 일관성 문제가 있습니다.
현재 로직에서 예약이 없을 때 랜덤 ID를 생성하고, 예약이 있을 때는 데이터베이스 ID를 사용하는 것은 일관성이 없습니다. 또한 createdAt을 현재 시간으로 설정하는 것도 실제 예약 생성 시간과 다를 수 있어 혼란을 야기할 수 있습니다.
TODO 주석에서도 언급된 것처럼, 예약 생성 시점부터 DB에 저장하거나 일관된 ID 생성 전략을 수립해야 합니다.
-//TODO 개선필요 -> createAt 정확성 및 reservationhId 생성 방법(예약생성부터 DB에 박아야하나....)
-String userName = userRepository.getReferenceById(Long.valueOf(userId)).getNickname();
-LocalDateTime createdAt = LocalDateTime.now();
-String reservationId = String.valueOf(
- ThreadLocalRandom.current().nextInt(1, 100));
+// 예약이 없는 경우의 기본값 설정을 명확히 하고 일관성 있게 처리
+String userName = null;
+LocalDateTime createdAt = null;
+String reservationId = null;Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/reservation/service/ReservationService.java
around lines 107 to 111, the reservation ID generation is inconsistent by using
a random ID when no reservation exists and a database ID otherwise, and the
createdAt timestamp is set to the current time rather than the actual
reservation creation time. To fix this, implement a consistent ID generation
strategy that either always uses the database-generated ID or a unified method,
and ensure the createdAt timestamp reflects the actual reservation creation
time, ideally by setting it when the reservation is persisted to the database.
작업 요약
Issue Link
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
버그 수정
기능 개선