-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor: store dto 내 waiting count 필드 추가 #150
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
Conversation
|
""" WalkthroughStoreController에서 전체 매장 조회 관련 두 GET 엔드포인트가 제거되었습니다. StorePageReadDto에는 대기 인원 수(waitingCount) 필드가 추가되고, 관련 정적 팩토리 메서드가 확장되었습니다. StoreService 및 StoreServiceImpl에서는 전체 매장 조회 관련 메서드들이 삭제되고, 나머지 매장 조회 로직에 Redis를 활용한 대기 인원 수 집계 기능이 통합되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Controller
participant Service
participant Redis
Controller->>Service: getAllStoresByPageAndDeparments(pageable)
Service->>Redis: ZCARD waiting:{storeId} (각 store별)
Service-->>Controller: StoreDepartmentReadResponse (waitingCount 포함)
sequenceDiagram
participant Controller
participant Service
participant Redis
Controller->>Service: getStoreByStoreId(storeId)
Service->>Redis: ZCARD waiting:{storeId}
Service-->>Controller: StorePageReadDto (waitingCount 포함)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Possibly related PRs
Suggested labels
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ 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: 5
🧹 Nitpick comments (4)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java (4)
147-154: 코드 중복을 리팩토링할 것을 권장합니다.
getAllStoresByPageAndDeparments메서드와 동일한 Redis 조회 로직이 중복됩니다. 공통 메서드로 추출하여 유지보수성을 향상시키는 것을 고려해보세요.공통 메서드 예시:
private Map<Long, Long> getWaitingCountMap(List<Long> storeIds) { return storeIds.stream() .collect(Collectors.toMap( Function.identity(), storeId -> { String key = "waiting:" + storeId; try { Long count = redisTemplate.opsForZSet().zCard(key); return count != null ? count : 0L; } catch (Exception e) { return 0L; } } )); }
56-64: Redis 대기 인원 수 조회 로직을 리팩토링하여 중복을 제거해보세요.현재 세 개의 메서드(
getAllStoresByPageAndDeparments,getStoreByStoreId,searchByKeywordNative)에서 동일한 Redis 조회 패턴이 반복됩니다. 공통 유틸리티 메서드로 추출하는 것을 고려해보세요.다음과 같이 공통 메서드를 추출할 수 있습니다:
+private Map<Long, Long> getWaitingCountMap(List<Long> storeIds) { + return storeIds.stream() + .collect(Collectors.toMap( + Function.identity(), + storeId -> { + String key = "waiting:" + storeId; + return redisTemplate.opsForZSet().zCard(key); + } + )); +} + +private Long getWaitingCount(Long storeId) { + String key = "waiting:" + storeId; + return redisTemplate.opsForZSet().zCard(key); +}
132-134: 주석 처리된 코드는 제거해주세요.Like 검색 관련 주석 처리된 코드가 남아있습니다. 더 이상 사용하지 않는다면 제거하는 것이 좋겠습니다.
-// Like 사용 -// List<Store> stores = storeRepository.findByNameContainingIgnoreCaseAndDeletedFalse(keyword); -// 풀텍스트인덱스 사용 List<Store> stores = storeRepository.searchByKeywordNative(keyword);
90-91: 변수명 일관성을 위해waitingCount로 통일해보세요.일부 메서드에서는
waitingSize, 다른 메서드에서는waitingCount를 사용하고 있습니다. 일관성을 위해waitingCount로 통일하는 것이 좋겠습니다.-Long waitingCount = - waitingSizeMap.getOrDefault(store.getStoreId(), 0L); +Long waitingCount = waitingSizeMap.getOrDefault(store.getStoreId(), 0L);Also applies to: 179-180
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/controller/StoreController.java(0 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadDto.java(3 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreService.java(0 hunks)nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java(7 hunks)
💤 Files with no reviewable changes (2)
- nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreService.java
- nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/controller/StoreController.java
🔇 Additional comments (7)
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/dto/StorePageReadDto.java (4)
18-18: 대기 인원 수 필드 추가가 적절합니다.
Long타입을 사용하여 null 값 처리가 가능하도록 구현된 점이 좋습니다.
30-30: 정적 팩토리 메서드 시그니처 업데이트가 올바릅니다.
waitingCount매개변수가 추가되고 빌더 패턴에서 적절히 설정되어 일관성이 유지되었습니다.Also applies to: 44-44
18-18: 대기 인원 수 필드 추가가 적절합니다.
waitingCount필드가Long타입으로 올바르게 추가되었습니다. null 값 처리도 자연스럽게 지원됩니다.
30-30: 팩토리 메서드 호출부 모두 새 시그니처로 업데이트됨
StorePageReadDto.fromEntity(store, …, waitingCount)호출이 모든 위치에서 4개의 인자를 사용하도록 수정된 것을 확인했습니다. 추가 검토 없이 승인합니다.nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java (3)
6-6: 적절한 import 추가입니다.스트림에서
Function.identity()사용을 위한 import가 올바르게 추가되었습니다.
90-92: DTO 팩토리 메서드 호출이 올바르게 업데이트되었습니다.새로운
waitingCount매개변수가 적절히 전달되고 있으며, 기본값 처리도 올바르게 구현되었습니다.Also applies to: 179-181
6-6: 적절한 임포트 추가입니다.
Function.identity()사용을 위한 임포트가 올바르게 추가되었습니다.
작업 요약
Issue Link
#149
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
신규 기능
버그 수정