Skip to content

Conversation

@Jjiggu
Copy link
Contributor

@Jjiggu Jjiggu commented Jul 25, 2025

작업 요약

  • store 조회 dto 내 waiting count 필드 추가

Issue Link

#149

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신규 기능

    • 매장 목록 및 상세 조회, 키워드 검색 결과에 각 매장의 대기 인원 수가 함께 표시됩니다.
  • 버그 수정

    • 불필요하거나 중복된 매장 전체 조회 관련 엔드포인트가 제거되었습니다.

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

coderabbitai bot commented Jul 25, 2025

"""

Walkthrough

StoreController에서 전체 매장 조회 관련 두 GET 엔드포인트가 제거되었습니다. StorePageReadDto에는 대기 인원 수(waitingCount) 필드가 추가되고, 관련 정적 팩토리 메서드가 확장되었습니다. StoreService 및 StoreServiceImpl에서는 전체 매장 조회 관련 메서드들이 삭제되고, 나머지 매장 조회 로직에 Redis를 활용한 대기 인원 수 집계 기능이 통합되었습니다.

Changes

파일/경로 변경 요약
.../controller/StoreController.java /all-stores, /low-wait/infinite-scroll GET 엔드포인트 및 관련 메서드 제거
.../dto/StorePageReadDto.java waitingCount 필드 추가, fromEntity 메서드 시그니처 및 구현 확장
.../service/StoreService.java getAllStores, getAllStoresByPage 메서드 선언 제거
.../service/StoreServiceImpl.java 위 두 메서드 구현 제거, 나머지 매장 조회 메서드에 Redis 기반 대기 인원 수 집계 및 DTO 생성 로직 반영

Sequence Diagram(s)

sequenceDiagram
    participant Controller
    participant Service
    participant Redis

    Controller->>Service: getAllStoresByPageAndDeparments(pageable)
    Service->>Redis: ZCARD waiting:{storeId} (각 store별)
    Service-->>Controller: StoreDepartmentReadResponse (waitingCount 포함)
Loading
sequenceDiagram
    participant Controller
    participant Service
    participant Redis

    Controller->>Service: getStoreByStoreId(storeId)
    Service->>Redis: ZCARD waiting:{storeId}
    Service-->>Controller: StorePageReadDto (waitingCount 포함)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Possibly related PRs

Suggested labels

enhancement
"""

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 5447f7b and 1c943de.

📒 Files selected for processing (2)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/controller/StoreController.java (1 hunks)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/controller/StoreController.java
  • nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java
✨ 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/#149-add-rank-field

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 25, 2025 02:55
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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between e692f68 and 5447f7b.

📒 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() 사용을 위한 임포트가 올바르게 추가되었습니다.

@Jjiggu Jjiggu merged commit c4ab742 into develop Jul 25, 2025
1 check passed
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